Return-Path: X-Original-To: apmail-stdcxx-issues-archive@minotaur.apache.org Delivered-To: apmail-stdcxx-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AA9FB98E9 for ; Thu, 16 Feb 2012 21:07:28 +0000 (UTC) Received: (qmail 66021 invoked by uid 500); 16 Feb 2012 21:07:28 -0000 Delivered-To: apmail-stdcxx-issues-archive@stdcxx.apache.org Received: (qmail 65993 invoked by uid 500); 16 Feb 2012 21:07:28 -0000 Mailing-List: contact issues-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list issues@stdcxx.apache.org Received: (qmail 65984 invoked by uid 99); 16 Feb 2012 21:07:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2012 21:07:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Feb 2012 21:07:21 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 998341BB653 for ; Thu, 16 Feb 2012 21:06:59 +0000 (UTC) Date: Thu, 16 Feb 2012 21:06:59 +0000 (UTC) From: "Stefan Teleman (Updated) (JIRA)" To: issues@stdcxx.apache.org Message-ID: <355925392.47994.1329426419630.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <969258590.47943.1329425459935.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (STDCXX-1062) std::vector::at() throws the wrong exception MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STDCXX-1062?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Stefan Teleman updated STDCXX-1062: ----------------------------------- Description: The std::vector::at() specialization throws the wrong exception: {code:title=test.cc|borderStyle=solid} #include #include #include static const size_t maxlen = 10; int main() { size_t i; bool b; int r; int ret = 0; int x = 0; std::vector vi(maxlen, 1); std::vector vb(maxlen, false); try { r = vi.at (12); } catch (std::out_of_range& e) { std::cerr << "std::vector::at(12): OK" << std::endl; ++x; } catch (std::exception& e) { std::cerr << "std::vector::at(12): wrong exception: " << e.what() << std::endl; ++ret; ++x; } catch ( ... ) { std::cerr << "std::vectorat(12): wrong exception!" << std::endl; ++ret; ++x; } try { b = vb.at(12); } catch (std::out_of_range& e) { std::cerr << "std::vector::at(12): OK" << std::endl; ++x; } catch (std::exception& e) { std::cerr << "std::vector::at(12): wrong exception: " << e.what() << std::endl; ++ret; ++x; } catch ( ... ) { std::cerr << "std::vector::at(12): wrong exception!" << std::endl; ++ret; ++x; } if (x == 0) { std::cerr << "no exception was thrown" << std::endl; ++ret; } return ret; } {code} 1. Output from GCC 4.5.0 on OpenSuSE Linux 11.3: {noformat} [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:04][1028]>> ./test-gcc std::vector::at(12): OK std::vector::at(12): OK [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:16][1029]>> echo $status 0 {noformat} 2. Output from SunPro C++ 12.2 with libCstd (default): {noformat} [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:25][1032]>> ./test-cstd std::vector::at(12): OK std::vector::at(12): OK [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:29][1033]>> echo $status 0 {noformat} 3. Output from Intel C++ 12.10: {noformat} [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:39:33][1053]>> ./test-icc std::vector::at(12): OK std::vector::at(12): OK [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:39:36][1054]>> echo $status 0 {noformat} 4. Output from SunPro C++ 12.2 with our patched stdcxx: {noformat} [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:31][1034]>> ./test-stdcxx std::vector::at(12): OK std::vector::at(12): OK [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:35][1035]>> echo $status 0 {noformat} 5. Output from Pathscale 4.0.12.1 (which didn't patch stdcxx): {noformat} [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:37][1036]>> ./test-pathscale std::vector::at(12): OK std::vector::at(12): wrong exception: /opt/pathscale/ekopath-4.0.12.1/include/4.0.12.1/stl/vector:1236: std::vector::reference std::vector::at(typename _Allocator::size_type) [with _Allocator = std::allocator]: length error: size 12 out of range [0, 10) [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:42][1037]>> echo $status 1 {noformat} was: The std::vector::at() specialization throws the wrong exception: {code:title=test.cc|borderStyle=solid} #include #include #include static const size_t maxlen = 10; int main() { size_t i; bool b; int r; int ret = 0; int x = 0; std::vector vi(maxlen, 1); std::vector vb(maxlen, false); try { r = vi.at (12); } catch (std::out_of_range& e) { std::cerr << "std::vector::at(12): OK" << std::endl; ++x; } catch (std::exception& e) { std::cerr << "std::vector::at(12): wrong exception: " << e.what() << std::endl; ++ret; ++x; } catch ( ... ) { std::cerr << "std::vectorat(12): wrong exception!" << std::endl; ++ret; ++x; } try { b = vb.at(12); } catch (std::out_of_range& e) { std::cerr << "std::vector::at(12): OK" << std::endl; ++x; } catch (std::exception& e) { std::cerr << "std::vector::at(12): wrong exception: " << e.what() << std::endl; ++ret; ++x; } catch ( ... ) { std::cerr << "std::vector::at(12): wrong exception!" << std::endl; ++ret; ++x; } if (x == 0) { std::cerr << "no exception was thrown" << std::endl; ++ret; } return ret; } {code} 1. Output from GCC 4.5.0 on OpenSuSE Linux 11.3: {noformat} [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:04][1028]>> ./test-gcc std::vector::at(12): OK std::vector::at(12): OK [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:16][1029]>> echo $status 0 {noformat} 2. Output from SunPro C++ 12.2 with libCstd (default): {noformat} [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:25][1032]>> ./test-cstd std::vector::at(12): OK std::vector::at(12): OK [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:29][1033]>> echo $status 0 {noformat} 3. Output from Intel C++ 12.10: {noformat} [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:39:33][1053]>> ./test-icc std::vector::at(12): OK std::vector::at(12): OK [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:39:36][1054]>> echo $status 0 {noformat} 4. Output from SunPro C++ 12.2 with our patched stdcxx: {noformat} [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:31][1034]>> ./test-stdcxx std::vector::at(12): OK std::vector::at(12): OK [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:35][1035]>> echo $status 0 {noformat} 5. Output from Pathscale 4.0.12.1 (which didn't patch stdcxx): {noformat} [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:37][1036]>> ./test-pathscale std::vector::at(12): OK std::vector::at(12): wrong exception: /opt/pathscale/ekopath-4.0.12.1/include/4.0.12.1/stl/vector:1236: std::vector::reference std::vector::at(typename _Allocator::size_type) [with _Allocator = std::allocator]: length error: size 12 out of range [0, 10) [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:42][1037]>> echo $status 1 {noformat} > std::vector::at() throws the wrong exception > -------------------------------------------------- > > Key: STDCXX-1062 > URL: https://issues.apache.org/jira/browse/STDCXX-1062 > Project: C++ Standard Library > Issue Type: Bug > Components: 23. Containers > Affects Versions: 4.2.1, 4.2.x, 4.3.x > Environment: Solaris 10 and 11 > RedHat Linux, OpenSuSE Linux > Defect is independent of platform and/or compiler > Reporter: Stefan Teleman > Labels: conformance, standard > Fix For: 4.2.2, 4.2.x, 4.3.x, 5.0.0 > > Attachments: stdcxx-1062.patch > > > The std::vector::at() specialization throws the wrong exception: > {code:title=test.cc|borderStyle=solid} > #include > #include > #include > static const size_t maxlen = 10; > int main() > { > size_t i; > bool b; > int r; > int ret = 0; > int x = 0; > std::vector vi(maxlen, 1); > std::vector vb(maxlen, false); > try > { > r = vi.at (12); > } > catch (std::out_of_range& e) > { > std::cerr << "std::vector::at(12): OK" << std::endl; > ++x; > } > catch (std::exception& e) > { > std::cerr << "std::vector::at(12): wrong exception: " > << e.what() << std::endl; > ++ret; > ++x; > } > catch ( ... ) > { > std::cerr << "std::vectorat(12): wrong exception!" > << std::endl; > ++ret; > ++x; > } > try > { > b = vb.at(12); > } > catch (std::out_of_range& e) > { > std::cerr << "std::vector::at(12): OK" << std::endl; > ++x; > } > catch (std::exception& e) > { > std::cerr << "std::vector::at(12): wrong exception: " > << e.what() << std::endl; > ++ret; > ++x; > } > catch ( ... ) > { > std::cerr << "std::vector::at(12): wrong exception!" > << std::endl; > ++ret; > ++x; > } > if (x == 0) > { > std::cerr << "no exception was thrown" << std::endl; > ++ret; > } > return ret; > } > {code} > 1. Output from GCC 4.5.0 on OpenSuSE Linux 11.3: > {noformat} > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:04][1028]>> ./test-gcc > std::vector::at(12): OK > std::vector::at(12): OK > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:16][1029]>> echo $status > 0 > {noformat} > 2. Output from SunPro C++ 12.2 with libCstd (default): > {noformat} > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:25][1032]>> ./test-cstd > std::vector::at(12): OK > std::vector::at(12): OK > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:29][1033]>> echo $status > 0 > {noformat} > 3. Output from Intel C++ 12.10: > {noformat} > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:39:33][1053]>> ./test-icc > std::vector::at(12): OK > std::vector::at(12): OK > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:39:36][1054]>> echo $status > 0 > {noformat} > 4. Output from SunPro C++ 12.2 with our patched stdcxx: > {noformat} > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:31][1034]>> ./test-stdcxx > std::vector::at(12): OK > std::vector::at(12): OK > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:35][1035]>> echo $status > 0 > {noformat} > 5. Output from Pathscale 4.0.12.1 (which didn't patch stdcxx): > {noformat} > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:37][1036]>> ./test-pathscale > std::vector::at(12): OK > std::vector::at(12): wrong exception: /opt/pathscale/ekopath-4.0.12.1/include/4.0.12.1/stl/vector:1236: std::vector::reference std::vector::at(typename _Allocator::size_type) [with _Allocator = std::allocator]: length error: size 12 out of range [0, 10) > [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/vector.bool][02/16/2012 15:37:42][1037]>> echo $status > 1 > {noformat} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira