You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@stdcxx.apache.org by "Stefan Teleman (Created) (JIRA)" <ji...@apache.org> on 2012/02/05 03:08:53 UTC

[jira] [Created] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
-------------------------------------------------------------------------------------------

                 Key: STDCXX-1057
                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
             Project: C++ Standard Library
          Issue Type: Bug
          Components: 21. Strings
    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
SUN C++ Compilers 12.1, 12.2, 12.3
Defect is independent of compiler and platform
            Reporter: Stefan Teleman
             Fix For: 4.2.x, 4.3.x, 5.0.0


in member function:

size_type basic_string<_CharT, _Traits, _Allocator>::max_size();

the maximum size of a basic_string is restricted to less than 65535 bytes.
The Standard is ambiguous as to what the max_size() of a std::string should
actually be (see LWG Core Issue 197). However, less than 65535 bytes for
the max_size of a std::string is rather small. GNU libstdc++ and stlport4
set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
to SIZE_MAX.

Perennial CPPVS explicitly tests for the creation of a std::string of size
greater than 65535. In the current stdcxx implementation, this test fails.

The max_size of a std::string should be significantly greater than 65535 bytes.

Patch for 4.2.1 to follow shortly.


--
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

        

[jira] [Issue Comment Edited] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Travis Vitek (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13201791#comment-13201791 ] 

Travis Vitek edited comment on STDCXX-1057 at 2/7/12 12:09 AM:
---------------------------------------------------------------

I agree with Martin. I'll even go further to say that the testcase is incorrect in that it expects an allocation larger than {{test_allocator<T>::max_size()}} to succeed.



                
      was (Author: vitek):
    I agree with Martin. I'll even go further to say that the testcase is incorrect in that it expects an allocation larger than {{test_allocator<T>::max_size()}} to succeed. Overriding {{allocate()}} to throw {{bad_alloc}} when such a request occurs should result in the testcase throwing.


                  
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Commented] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Travis Vitek (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13202609#comment-13202609 ] 

Travis Vitek commented on STDCXX-1057:
--------------------------------------

The question here is not what value should {{string::max_size()}} or {{allocator::max_size()}} return. The question is should the {{std::basic_string<T>}} constructors use {{basic_string<T>::max_size()}} or {{allocator::max_size()}} at all, or should they just try to make the allocation request and allow the exception to propagate out to the caller?

I believe that Martin is suggesting the constructors should consult {{basic_string<T>::max_size()}} before making the allocation, and the Perennial testcase seems to think that this behavior is forbidden. I read through all of 21.3.1 and didn't see anything that indicates there is a requirement either way. There are requirements relating to this for functions that grow the string, but I don't see anything for the string constructors. So, as Martin suggests, this is _unspecified behavior_, and as such, the actual behavior is _implementation defined_.

That said, I did find [LWG#83|http://www.open-std.org/Jtc1/sc22/wg21/docs/lwg-defects.html#83], which indicates the addition of the following paragraph to the requirements of {{std::basic_string}}

{quote}
For any string operation, if as a result of the operation, size() would exceed max_size() then the operation throws length_error.
{quote}

A quick check of the C++11 standard shows that as [string.require] p1.
                
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Updated] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Farid Zaripov (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Farid Zaripov updated STDCXX-1057:
----------------------------------

    Comment: was deleted

(was: Could not reproduce on MSVC 10 with stdcxx 4.2.1 and 4.2.2)
    
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Commented] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Martin Sebor (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13201524#comment-13201524 ] 

Martin Sebor commented on STDCXX-1057:
--------------------------------------

I don't think C++ specifies the behavior of the test case. stdcxx {{std::basic_string::max_size()}} happens to use {{std::basic_string::allocator_type::max_size()}} and, as required, throws {{std::length_error}} when any operation on the string object would exceed that size (minus a small constant). This behavior is by design. The test {{[21.string.capacity.cpp|http://svn.apache.org/repos/asf/stdcxx/tags/4.2.1/tests/strings/21.string.capacity.cpp]}} exercises this feature.

                
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Updated] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Stefan Teleman (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Teleman updated STDCXX-1057:
-----------------------------------

    Description: 
in member function:

size_type basic_string<_CharT, _Traits, _Allocator>::max_size();

the maximum size of a basic_string is restricted to less than 65535 bytes.
The Standard is ambiguous as to what the max_size() of a std::string should
actually be (see LWG Core Issue 197). However, less than 65535 bytes for
the max_size of a std::string is rather small. GNU libstdc++ and stlport4
set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
to SIZE_MAX.

Perennial CPPVS explicitly tests for the creation of a std::string of size
greater than 65535. In the current stdcxx implementation, this test fails.

The max_size of a std::string should be significantly greater than 65535 bytes.

Test to reproduce the defect:

{code:title=test.cc|borderStyle=solid}
#include <iostream>
#include <string>

const size_t maxlen = 65536U;
char array[maxlen];

struct test_traits : public std::char_traits<char>
{ };

template<class T>
struct test_alloc : public std::allocator<T>
{
    typedef typename std::allocator<T>::size_type size_type;

    template<class Y>
    struct rebind
    {
        typedef test_alloc<Y> other;
    };

    test_alloc() throw() { }
    test_alloc(const test_alloc& rhs) throw() { }

    template<class Y>
    test_alloc(const test_alloc<Y>& y) throw() { }

    ~test_alloc() throw() { }

    size_type max_size() const throw() { return maxlen; }
};

int main()
{
    typedef
    std::basic_string<char, test_traits, test_alloc<char> > test_string;

    int ret = 0;
    size_t i, j;

    for (i = 0; i < maxlen; i++)
        array[i] = '*';

    array[maxlen - 1] = '\0';

    for (i = 0; i < maxlen - 1; i+= 8)
    {
        array[i] = '\0';
        test_string s(array);

        j = s.size();
        array[i] = '-';

        if (i != j)
        {
            std::cerr << "i = " << i << " j = " << j << " expected i == j"
                      << std::endl;
            ret = 1;
            break;
        }
    }

    return ret;
}
{code}

1. Output from GCC 4.5.0:
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
0
{noformat}

2. Output from Sun C++ 12.2 with stlport:
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
0
{noformat}

3. Output from Sun C++ 12.2 with our patched stdcxx:
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
0
{noformat}

4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
{noformat}
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
Terminating due to uncaught exception 0x614240 of type std::length_error
Abort (core dumped)
[steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
134
{noformat}

Patch for 4.2.1 to follow shortly.


  was:
in member function:

size_type basic_string<_CharT, _Traits, _Allocator>::max_size();

the maximum size of a basic_string is restricted to less than 65535 bytes.
The Standard is ambiguous as to what the max_size() of a std::string should
actually be (see LWG Core Issue 197). However, less than 65535 bytes for
the max_size of a std::string is rather small. GNU libstdc++ and stlport4
set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
to SIZE_MAX.

Perennial CPPVS explicitly tests for the creation of a std::string of size
greater than 65535. In the current stdcxx implementation, this test fails.

The max_size of a std::string should be significantly greater than 65535 bytes.

Patch for 4.2.1 to follow shortly.


    
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Closed] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Stefan Teleman (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Teleman closed STDCXX-1057.
----------------------------------

    Resolution: Won't Fix
    Regression: Regression,Unit Test Broken  (was: Regression)

Outright refusal from upstream to even consider this a bug.

                
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Travis Vitek (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13202626#comment-13202626 ] 

Travis Vitek commented on STDCXX-1057:
--------------------------------------

Also, just for information, the GNU implementation sets {{basic_string<T>::max_size()}} to something smaller than {{SIZE_MAX}} (see [basic_string.tcc|http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/include/bits/basic_string.tcc?revision=179961&view=markup]:53). So if the testcase used a different magic number, you'd see the same behavior as stdcxx.


                
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Commented] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Stefan Teleman (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13201714#comment-13201714 ] 

Stefan Teleman commented on STDCXX-1057:
----------------------------------------

For this particular case, the Standard doesn't really specify a behavior, by virtue of the fact that it is ambiguous. There are several possible interpretations:

{noformat}
1. 20.1.5, t32 "the largest value that can meaningfully be passed to X::allocate()"
2. 23.1, t65 "size() of the largest possible container"
3. 21.3.3., p3 "The maximum size of the string -- see 23.1, t65"
4. LWG Core Issue 197
{noformat}

The question then becomes "what do other known sane implementations do?"

                
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Commented] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Stefan Teleman (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13202745#comment-13202745 ] 

Stefan Teleman commented on STDCXX-1057:
----------------------------------------

Yes, GNU libstdc++ sets it to (SIZE_MAX / 4) which means 1GB > 65K.

Stlport sets it to SIZE_MAX. SunPro C++ sets it to SIZE_MAX both in libCstd.so and libstdcxx4.so.


                
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Commented] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Farid Zaripov (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13201149#comment-13201149 ] 

Farid Zaripov commented on STDCXX-1057:
---------------------------------------

Could not reproduce on MSVC 10 with stdcxx 4.2.1 and 4.2.2
                
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Commented] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Travis Vitek (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13201791#comment-13201791 ] 

Travis Vitek commented on STDCXX-1057:
--------------------------------------

I agree with Martin. I'll even go further to say that the testcase is incorrect in that it expects an allocation larger than {{test_allocator<T>::max_size()}} to succeed. Overriding {{allocate()}} to throw {{bad_alloc}} when such a request occurs should result in the testcase throwing.


                
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Issue Comment Edited] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Travis Vitek (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13202609#comment-13202609 ] 

Travis Vitek edited comment on STDCXX-1057 at 2/8/12 12:48 AM:
---------------------------------------------------------------

The question here is not what value should {{string::max_size()}} or {{allocator::max_size()}} return. The question is should the {{std::basic_string<T>}} constructors use {{allocator::max_size()}} at all, or should they just try to make the allocation request and allow the exception to propagate out to the caller?

I believe that Martin is suggesting the constructors should consult {{allocator::max_size()}} before making the allocation, and the Perennial testcase seems to think that this behavior is forbidden. I read through all of 21.3.1 and didn't see anything that indicates there is a requirement either way. There are requirements relating to this for functions that grow the string, but I don't see anything for the string constructors. So, as Martin suggests, this is _unspecified behavior_, and as such, the actual behavior is _implementation defined_.
                
      was (Author: vitek):
    The question here is not what value should {{string::max_size()}} or {{allocator::max_size()}} return. The question is should the {{std::basic_string<T>}} constructors use {{basic_string<T>::max_size()}} or {{allocator::max_size()}} at all, or should they just try to make the allocation request and allow the exception to propagate out to the caller?

I believe that Martin is suggesting the constructors should consult {{basic_string<T>::max_size()}} before making the allocation, and the Perennial testcase seems to think that this behavior is forbidden. I read through all of 21.3.1 and didn't see anything that indicates there is a requirement either way. There are requirements relating to this for functions that grow the string, but I don't see anything for the string constructors. So, as Martin suggests, this is _unspecified behavior_, and as such, the actual behavior is _implementation defined_.

That said, I did find [LWG#83|http://www.open-std.org/Jtc1/sc22/wg21/docs/lwg-defects.html#83], which indicates the addition of the following paragraph to the requirements of {{std::basic_string}}

{quote}
For any string operation, if as a result of the operation, size() would exceed max_size() then the operation throws length_error.
{quote}

A quick check of the C++11 standard shows that as [string.require] p1.
                  
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Updated] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Travis Vitek (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-1057:
---------------------------------

    Comment: was deleted

(was: I agree with Martin. I'll even go further to say that the testcase is incorrect in that it expects an allocation larger than {{test_allocator<T>::max_size()}} to succeed.


)
    
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Updated] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Stefan Teleman (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Teleman updated STDCXX-1057:
-----------------------------------

    Patch Info: Patch Available
    
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Updated] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Stefan Teleman (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Teleman updated STDCXX-1057:
-----------------------------------

    Attachment: test.cc
    
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Commented] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Martin Sebor (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13202606#comment-13202606 ] 

Martin Sebor commented on STDCXX-1057:
--------------------------------------

I don't have access to too many other libraries but, IIRC, from talking to other implementers on the C++ committee when the function was discussed, other libraries tend to simply hardcode some large constant directly into {{basic_string::max_size()}}, making the function not terribly useful. The committee discussed a proposal to make the function more useful and chose to do nothing. Library Issue [197|http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-closed.html#197] has the background. FWIW, I argued for a change that would make it possible (but not required) to provide (4) in the issue because that, in my view, would make the function the most useful. This is what stdcxx does.
                
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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

        

[jira] [Updated] (STDCXX-1057) attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1

Posted by "Stefan Teleman (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Teleman updated STDCXX-1057:
-----------------------------------

    Attachment: stdcxx-1057.patch
    
> attempting to create a std::string of size 65535 or greater fails with Perennial CPPVS V8.1
> -------------------------------------------------------------------------------------------
>
>                 Key: STDCXX-1057
>                 URL: https://issues.apache.org/jira/browse/STDCXX-1057
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 21. Strings
>    Affects Versions: 4.2.1, 4.2.x, 4.3.x, 5.0.0
>         Environment: Solaris 10 and 11, RedHat Linux, OpenSuSE Linux
> SUN C++ Compilers 12.1, 12.2, 12.3
> Defect is independent of compiler and platform
>            Reporter: Stefan Teleman
>              Labels: conformance, features, standards, test
>             Fix For: 4.2.x, 4.3.x, 5.0.0
>
>         Attachments: stdcxx-1057.patch, test.cc
>
>
> in member function:
> size_type basic_string<_CharT, _Traits, _Allocator>::max_size();
> the maximum size of a basic_string is restricted to less than 65535 bytes.
> The Standard is ambiguous as to what the max_size() of a std::string should
> actually be (see LWG Core Issue 197). However, less than 65535 bytes for
> the max_size of a std::string is rather small. GNU libstdc++ and stlport4
> set std::string::max_size to (SIZE_MAX / 4) (i.e. 1GB). Solaris sets it
> to SIZE_MAX.
> Perennial CPPVS explicitly tests for the creation of a std::string of size
> greater than 65535. In the current stdcxx implementation, this test fails.
> The max_size of a std::string should be significantly greater than 65535 bytes.
> Test to reproduce the defect:
> {code:title=test.cc|borderStyle=solid}
> #include <iostream>
> #include <string>
> const size_t maxlen = 65536U;
> char array[maxlen];
> struct test_traits : public std::char_traits<char>
> { };
> template<class T>
> struct test_alloc : public std::allocator<T>
> {
>     typedef typename std::allocator<T>::size_type size_type;
>     template<class Y>
>     struct rebind
>     {
>         typedef test_alloc<Y> other;
>     };
>     test_alloc() throw() { }
>     test_alloc(const test_alloc& rhs) throw() { }
>     template<class Y>
>     test_alloc(const test_alloc<Y>& y) throw() { }
>     ~test_alloc() throw() { }
>     size_type max_size() const throw() { return maxlen; }
> };
> int main()
> {
>     typedef
>     std::basic_string<char, test_traits, test_alloc<char> > test_string;
>     int ret = 0;
>     size_t i, j;
>     for (i = 0; i < maxlen; i++)
>         array[i] = '*';
>     array[maxlen - 1] = '\0';
>     for (i = 0; i < maxlen - 1; i+= 8)
>     {
>         array[i] = '\0';
>         test_string s(array);
>         j = s.size();
>         array[i] = '-';
>         if (i != j)
>         {
>             std::cerr << "i = " << i << " j = " << j << " expected i == j"
>                       << std::endl;
>             ret = 1;
>             break;
>         }
>     }
>     return ret;
> }
> {code}
> 1. Output from GCC 4.5.0:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:34][2162]>> ./test-gcc
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:48][2163]>> echo $status
> 0
> {noformat}
> 2. Output from Sun C++ 12.2 with stlport:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:50][2164]>> ./test-ss122-stlport 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:16:58][2165]>> echo $status
> 0
> {noformat}
> 3. Output from Sun C++ 12.2 with our patched stdcxx:
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:00][2166]>> ./test-ss122-stdcxx 
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:06][2167]>> echo $status
> 0
> {noformat}
> 4. Output from Pathscale 4.0.12.1 (which did not patch stdcxx):
> {noformat}
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:08][2168]>> ./test-pathscale 
> Terminating due to uncaught exception 0x614240 of type std::length_error
> Abort (core dumped)
> [steleman@darthvader][/src/steleman/programming/stdcxx-ss122/bugfixes-sunw/6889771][02/06/2012 10:17:13][2169]>> echo $status
> 134
> {noformat}
> Patch for 4.2.1 to follow shortly.

--
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