[ 
https://issues.apache.org/jira/browse/STDCXX-1062?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Farid Zaripov resolved STDCXX-1062.
-----------------------------------

    Resolution: Fixed

Fixed with adding a regression test thus: 
http://svn.apache.org/viewvc?view=revision&revision=1291062
                
> std::vector<bool>::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
>            Assignee: Farid Zaripov
>              Labels: conformance, standard
>             Fix For: 4.2.2, 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1062.patch
>
>
> The std::vector<bool>::at() specialization throws the wrong exception:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <vector>
> #include <stdexcept>
> static const size_t maxlen = 10;
> int main()
> {
>     size_t i;
>     bool b;
>     int r;
>     int ret = 0;
>     int x = 0;
>     std::vector<int> vi(maxlen, 1);
>     std::vector<bool> vb(maxlen, false);
>     try
>     {
>         r = vi.at (12);
>     }
>     catch (std::out_of_range& e)
>     {
>         std::cerr << "std::vector<int>::at(12): OK" << std::endl;
>         ++x;
>     }
>     catch (std::exception& e)
>     {
>         std::cerr << "std::vector<int>::at(12): wrong exception: "
>                 << e.what() << std::endl;
>         ++ret;
>         ++x;
>     }
>     catch ( ... )
>     {
>         std::cerr << "std::vector<int::>at(12): wrong exception!"
>                 << std::endl;
>         ++ret;
>         ++x;
>     }
>     try
>     {
>         b = vb.at(12);
>     }
>     catch (std::out_of_range& e)
>     {
>         std::cerr << "std::vector<bool>::at(12): OK" << std::endl;
>         ++x;
>     }
>     catch (std::exception& e)
>     {
>         std::cerr << "std::vector<bool>::at(12): wrong exception: "
>                 << e.what() << std::endl;
>         ++ret;
>         ++x;
>     }
>     catch ( ... )
>     {
>         std::cerr << "std::vector<boolt>::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<int>::at(12): OK
> std::vector<bool>::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<int>::at(12): OK
> std::vector<bool>::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<int>::at(12): OK
> std::vector<bool>::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<int>::at(12): OK
> std::vector<bool>::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<int>::at(12): OK
> std::vector<bool>::at(12): wrong exception: 
> /opt/pathscale/ekopath-4.0.12.1/include/4.0.12.1/stl/vector:1236: 
> std::vector<bool, _Allocator>::reference std::vector<bool, 
> _Allocator>::at(typename _Allocator::size_type) [with _Allocator = 
> std::allocator<bool>]: 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

        

Reply via email to