public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37557] New: mixing wide and plain streams causes stream-errors (g++ 4.2.3 also affected)
@ 2008-09-17 7:18 nikola dot radovanovic at dmsgroup dot rs
2009-12-26 18:50 ` [Bug libstdc++/37557] mixing wide and plain streams causes stream-errors (g++ 4.1.0 " paolo dot carlini at oracle dot com
2009-12-30 12:51 ` paolo dot carlini at oracle dot com
0 siblings, 2 replies; 3+ messages in thread
From: nikola dot radovanovic at dmsgroup dot rs @ 2008-09-17 7:18 UTC (permalink / raw)
To: gcc-bugs
hi, recetly i found out something that is possible/probably bug in g++. so far
i have tested on 4.1.0 and 4.2.3. on previous versions there were no such error
(tried with 3.3.5).
here is brief description: i use string and wstring (and appropriate cin/cout
and wcin/wcout) in same console app that simulates user login (for both ascii
and wide). i display 'menu' for user to 'choose' will it try to 'login' with
wide or ascii strings. if i uses ascii 'menu', then ascii 'login' works, but
wide not. on the other hand, if i use wide strings for 'menu', ascii 'login'
does not work, but wide do work. it seems that g++ can not use (or better say,
do not use properly) stream of type other than initial stream type
here are g++ versions that fails:
---------------------------------------------------------------
4.1.0 (not working)
---------------------------------------------------------------
nikola.radovanovic@test-k69-1:~/tmp> g++ -v -save-temps test.cpp
Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,java,ada --enable-checking=release
--with-gxx-include-dir=/usr/include/c++/4.1.0 --enable-ssp --disable-libssp
--enable-java-awt=gtk --enable-gtk-cairo --disable-libjava-multilib
--with-slibdir=/lib64 --with-system-zlib --enable-shared --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --without-system-libunwind --with-cpu=generic
--host=x86_64-suse-linux
Thread model: posix
gcc version 4.1.0 (SUSE Linux)
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/cc1plus -E -quiet -v -D_GNU_SOURCE
test.cpp -mtune=generic -fpch-preprocess -o test.ii
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.1.0
/usr/include/c++/4.1.0/x86_64-suse-linux
/usr/include/c++/4.1.0/backward
/usr/local/include
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/include
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/include
/usr/include
End of search list.
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/cc1plus -fpreprocessed test.ii -quiet
-dumpbase test.cpp -mtune=generic -auxbase test -version -o test.s
GNU C++ version 4.1.0 (SUSE Linux) (x86_64-suse-linux)
compiled by GNU C version 4.1.0 (SUSE Linux).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64086
Compiler executable checksum: 9b76824cc9116a4f771ea2bae2ced729
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/bin/as -V
-Qy -o test.o test.s
GNU assembler version 2.16.91.0.5 (x86_64-suse-linux) using BFD version
2.16.91.0.5 20051219 (SUSE Linux)
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/collect2 --eh-frame-hdr -m elf_x86_64
-dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/crt1.o
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/crti.o
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/crtbegin.o
-L/usr/lib64/gcc/x86_64-suse-linux/4.1.0
-L/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64
-L/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../x86_64-suse-linux/lib
-L/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../.. test.o -lstdc++ -lm -lgcc_s
-lgcc -lc -lgcc_s -lgcc /usr/lib64/gcc/x86_64-suse-linux/4.1.0/crtend.o
/usr/lib64/gcc/x86_64-suse-linux/4.1.0/../../../../lib64/crtn.o
---------------------------------------------------------------
4.2.3 (not working)
---------------------------------------------------------------
korisnik@nradovanovic:~/tmp$ g++ -v -save-temps test.cpp
Reading specs from /usr/lib/gcc/i486-slackware-linux/4.2.3/specs
Target: i486-slackware-linux
Configured with: ../gcc-4.2.3/configure --prefix=/usr --enable-shared
--enable-languages=ada,c,c++,fortran,java,objc --enable-threads=posix
--enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose
--with-arch=i486 --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 4.2.3
/usr/libexec/gcc/i486-slackware-linux/4.2.3/cc1plus -E -quiet -v -D_GNU_SOURCE
test.cpp -mtune=i486 -march=i486 -fpch-preprocess -o test.ii
ignoring duplicate directory "/usr/lib/qt/include"
ignoring nonexistent directory
"/usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../i486-slackware-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/qt/include
/usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../include/c++/4.2.3
/usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../include/c++/4.2.3/i486-slackware-linux
/usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../include/c++/4.2.3/backward
/usr/local/include
/usr/lib/gcc/i486-slackware-linux/4.2.3/include
/usr/include
End of search list.
/usr/libexec/gcc/i486-slackware-linux/4.2.3/cc1plus -fpreprocessed test.ii
-quiet -dumpbase test.cpp -mtune=i486 -march=i486 -auxbase test -version -o
test.s
GNU C++ version 4.2.3 (i486-slackware-linux)
compiled by GNU C version 4.2.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 6e821a92395a6d11d0fecef5a903c36b
/usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../i486-slackware-linux/bin/as
-V -Qy -o test.o test.s
GNU assembler version 2.17.50.0.17 (i486-slackware-linux) using BFD version
(Linux/GNU Binutils) 2.17.50.0.17.20070615
/usr/libexec/gcc/i486-slackware-linux/4.2.3/collect2 --eh-frame-hdr -m
elf_i386 -dynamic-linker /lib/ld-linux.so.2
/usr/lib/gcc/i486-slackware-linux/4.2.3/../../../crt1.o
/usr/lib/gcc/i486-slackware-linux/4.2.3/../../../crti.o
/usr/lib/gcc/i486-slackware-linux/4.2.3/crtbegin.o
-L/usr/lib/gcc/i486-slackware-linux/4.2.3
-L/usr/lib/gcc/i486-slackware-linux/4.2.3
-L/usr/lib/gcc/i486-slackware-linux/4.2.3/../../../../i486-slackware-linux/lib
-L/usr/lib/gcc/i486-slackware-linux/4.2.3/../../.. test.o -lstdc++ -lm -lgcc_s
-lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i486-slackware-linux/4.2.3/crtend.o
/usr/lib/gcc/i486-slackware-linux/4.2.3/../../../crtn.o
---------------------------------------------------------------
3.3.5 (working)
---------------------------------------------------------------
nikola.radovanovic@test-k069-64:~/tmp> g++ -v -save-temps test.cpp
Reading specs from /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --enable-languages=c,c++,f77,objc,java,ada
--disable-checking --libdir=/usr/lib64 --enable-libgcj --with-slibdir=/lib64
--with-system-zlib --enable-shared --enable-__cxa_atexit x86_64-suse-linux
Thread model: posix
gcc version 3.3.5 20050117 (prerelease) (SUSE Linux)
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/cc1plus -E -D__GNUG__=3 -quiet -v
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=5 -D_GNU_SOURCE test.cpp
test.ii
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/3.3.5
/usr/include/c++/3.3.5/x86_64-suse-linux
/usr/include/c++/3.3.5/backward
/usr/local/include
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/include
/usr/x86_64-suse-linux/include
/usr/include
End of search list.
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/cc1plus -fpreprocessed test.ii
-quiet -dumpbase test.cpp -auxbase test -version -o test.s
GNU C++ version 3.3.5 20050117 (prerelease) (SUSE Linux) (x86_64-suse-linux)
compiled by GNU C version 3.3.5 20050117 (prerelease) (SUSE Linux).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../x86_64-suse-linux/bin/as
-V -Qy -o test.o test.s
GNU assembler version 2.15.94.0.2.2 (x86_64-suse-linux) using BFD version
2.15.94.0.2.2 20041220 (SuSE Linux)
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/collect2 --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../lib64/crt1.o
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../lib64/crti.o
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/crtbegin.o
-L/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5
-L/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../x86_64-suse-linux/lib
-L/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../lib64
-L/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../.. -L/lib/../lib64
-L/usr/lib/../lib64 test.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/crtend.o
/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../lib64/crtn.o
---------------------------------------------------------------
test.cpp
NOTE: wide streams works, but ascii not
---------------------------------------------------------------
#include <iostream>
#include <string>
using namespace std;
const string g_strPromptA = ">> ";
const wstring g_strPromptW = L">> ";
void PrintMainMenu()
{
cout << "Choose: " << endl
<< "1)\tLoginA" << endl
<< "2)\tLoginW" << endl
<< "q)\tQuit" << endl;
}
void InputStringA(const string& strPrompt, string& strOut)
{
cout << strPrompt;
cin >> strOut;
}
void InputStringW(const wstring& strPrompt, wstring& strOut)
{
wcout << strPrompt;
wcin >> strOut;
}
void PrintUnknownOption()
{
cout << "Unknown option entered. Try again." << endl;
}
void LoginUserA()
{
string str;
InputStringA("Enter usernameA: ", str);
cout << "Logged user - " << str << endl;
}
void LoginUserW()
{
wstring str;
InputStringW(L"Enter usernameW: ", str);
wcout << L"Logged user - " << str << endl;
}
int main(int argc, char** argv)
{
wstring strChoice;
do
{
PrintMainMenu();
InputStringW(g_strPromptW, strChoice);
if (strChoice == L"1")
LoginUserA();
else if (strChoice == L"2")
LoginUserW();
else if (strChoice != L"q")
PrintUnknownOption();
} while (strChoice != L"q");
return 0;
}
---------------------------------------------------------------
NOTE: change main function to this, and you will see ascii
streams works now, but wide not
---------------------------------------------------------------
int main(int argc, char** argv)
{
string strChoice;
do
{
PrintMainMenu();
InputStringA(g_strPromptA, strChoice);
if (strChoice == "1")
LoginUserA();
else if (strChoice == "2")
LoginUserW();
else if (strChoice != "q")
PrintUnknownOption();
} while (strChoice != "q");
return 0;
}
--
Summary: mixing wide and plain streams causes stream-errors (g++
4.2.3 also affected)
Product: gcc
Version: 4.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nikola dot radovanovic at dmsgroup dot rs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37557
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/37557] mixing wide and plain streams causes stream-errors (g++ 4.1.0 also affected)
2008-09-17 7:18 [Bug c++/37557] New: mixing wide and plain streams causes stream-errors (g++ 4.2.3 also affected) nikola dot radovanovic at dmsgroup dot rs
@ 2009-12-26 18:50 ` paolo dot carlini at oracle dot com
2009-12-30 12:51 ` paolo dot carlini at oracle dot com
1 sibling, 0 replies; 3+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-26 18:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from paolo dot carlini at oracle dot com 2009-12-26 18:50 -------
Yes, this is exactly what the Standard says, see 27.3/2, the behavior changed,
we are more conforming lately.
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Component|c++ |libstdc++
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37557
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/37557] mixing wide and plain streams causes stream-errors (g++ 4.1.0 also affected)
2008-09-17 7:18 [Bug c++/37557] New: mixing wide and plain streams causes stream-errors (g++ 4.2.3 also affected) nikola dot radovanovic at dmsgroup dot rs
2009-12-26 18:50 ` [Bug libstdc++/37557] mixing wide and plain streams causes stream-errors (g++ 4.1.0 " paolo dot carlini at oracle dot com
@ 2009-12-30 12:51 ` paolo dot carlini at oracle dot com
1 sibling, 0 replies; 3+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-30 12:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from paolo dot carlini at oracle dot com 2009-12-30 12:51 -------
*** Bug 42552 has been marked as a duplicate of this bug. ***
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |debian-gcc at lists dot
| |debian dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37557
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-12-30 12:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-17 7:18 [Bug c++/37557] New: mixing wide and plain streams causes stream-errors (g++ 4.2.3 also affected) nikola dot radovanovic at dmsgroup dot rs
2009-12-26 18:50 ` [Bug libstdc++/37557] mixing wide and plain streams causes stream-errors (g++ 4.1.0 " paolo dot carlini at oracle dot com
2009-12-30 12:51 ` paolo dot carlini at oracle dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).