Severe problems with the new locale code
Peter Schmid
schmid@snake.iap.physik.tu-darmstadt.de
Sun Dec 16 13:41:00 GMT 2001
After bootstrapping the gcc 3.1 compiler today I tried some code employing
locale specific IO. Always I get a segmentation fault in
std::ctype<char>::is. LANG is set to C, but setting LANG to a
different value makes no difference.
For example, after compiling the following code tl.C by gcc 3.1.
cat tl.C
#include <iostream>
#include <locale>
using namespace std;
int main()
{
cin.imbue(locale("de_DE"));
double d;
while (cin >> d) {
cout << d << endl;
}
}
g++ -v -o tl tl.C -W -Wall -g
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-clocale=gnu --enable-languages=c,c++,f77,objc
Thread model: posix
gcc version 3.1 20011216 (experimental)
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -W -Wall -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tl.C -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase tl.C -g -W -Wall -version -o /tmp/cc3UFqVe.s
GNU CPP version 3.1 20011216 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.1 20011216 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 3.1 20011216 (experimental).
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/g++-v3
/usr/local/include/g++-v3/i686-pc-linux-gnu
/usr/local/include/g++-v3/backward
/usr/local/include
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include
/usr/include
End of search list.
as -V -Qy -o /tmp/cc29WHQ0.o /tmp/cc3UFqVe.s
GNU assembler version 2.11.90.0.29 (i486-suse-linux) using BFD version 2.11.90.0.29
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o tl /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtbegin.o -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1 -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../.. /tmp/cc29WHQ0.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtend.o /usr/lib/crtn.o
The executable crashes with a segmentation fault.
./tl
1,34
Segmentation fault (core dumped)
GNU gdb 5.0
Copyright 2001 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) r
Starting program: ./tl
1,23
Program received signal SIGSEGV, Segmentation fault.
0x0804b71e in std::ctype<char>::is(unsigned short, char) const (
this=0x804fd88, __m=8192, __c=49)
at /usr/local/include/g++-v3/i686-pc-linux-gnu/bits/ctype_inline.h:40
(gdb) bt
#0 0x0804b71e in std::ctype<char>::is(unsigned short, char) const (
this=0x804fd88, __m=8192, __c=49)
at /usr/local/include/g++-v3/i686-pc-linux-gnu/bits/ctype_inline.h:40
#1 0x0804a9bc in std::istream::sentry::sentry(std::istream&, bool) (
this=0xbffff65f, __in=@0x804d188, __noskipws=false)
at /usr/local/include/g++-v3/bits/istream.tcc:52
#2 0x0804a31e in std::istream::operator>>(double&) (this=0x804d188,
__n=@0xbffff69c) at /usr/local/include/g++-v3/bits/istream.tcc:396
#3 0x0804a0a4 in main () at tl.C:9
#4 0x4010d7ee in __libc_start_main () from /lib/libc.so.6
(gdb) info locals
this = (ctype<char> *) 0x804fd88
__m = 8192
__c = 0 '\000'
Hope this helps
Peter Schmid
More information about the Libstdc++
mailing list