wstring::length() does not work properly with --short-wchar

I'm not sure if this bug is in gcc or glibc. It could be that gcc does not
properly set a certain variable with --short-wchar, or, it could be that glibc
does not properly implement wstring, always assuming a 4-byte wchar_t.

Here is a sample:

// tmp2.cpp
#include <iostream>

int main(int argc, char ** argv)
{
        std::wstring wstr = L"Hello, World!";
        std::wcout << wstr.length() << std::endl;
        return 0;
}

$ g++ -o tmp tmp2.cpp
$ ./tmp
13
$ g++ -o tmp tmp2.cpp --short-wchar
$ ./tmp
19

They should both say 13. ymmv, but the length value given is usually wrong. How
wrong may vary.


-- 
           Summary: wstring::length() does not work properly with --short-
                    wchar
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jigglypuff at spambob dot com
 GCC build triplet: ?
  GCC host triplet: i686-linux-gnu
GCC target triplet: i486-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32240

Reply via email to