This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/4790: LANG=C rejects-legal
- From: "Golubev I. N." <gin at mo dot msk dot ru>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 29 Nov 2001 18:59:19 (GMT)
- Subject: c/4790: LANG=C rejects-legal
- References: <02573be6b30362-gin@mo.msk.ru>
[Get raw message]
Abstract: system libc bug, not gcc bug. I consider closed.
The broken function directly affecting gcc is atoi() which always
returns 0 when LANG=C. This causes final.c:3526 to use wrong index in
rtx array.
atoi() gets broken this way because it uses isdigit() which in turn is
based on a table stored in global `__ctype' var in `libc.so'. That
`__ctype' definition in `libc.so' is broken in that `isdigit' assumes
it to be in initialized data section, but program can link so that it
gets uninitialized, zeroed. `setlocale (LC_CTYPE, "")' call done in
`toplev.c' fixes that, but not when LANG=C. In this case the var
remains uninitialized.
`libc.so' is an ar archive containing both elf relocatable `*.o' files
and shared library `libc.so.1' file. `libc.so.1' definition is right,
initialized. But `libc.so' also contains `fk_ctype.o' which defines a
broken, uninitialized duplicate of `__ctype'.
That broken duplicate can get into a shared library being linked
against `-lc' (which is normal), yielding a broken shared library. It
can still be all right when program binary itself contains `__ctype'
since in this case dynamic linker will initialize `__ctype' instance
in program binary correctly.
When program binary itself does not contain `__ctype', broken
`__ctype' value from shared library gets used by `isdigit' inside
`atoi'.
This is the case for my `cc1' program since (1) it uses
<safe-ctype.h>, not system <ctype.h>; (2) gcc is configured
--without-included-gettext (see original report
<http://gcc.gnu.org/ml/gcc-bugs/2001-11/msg00165.html>), and is linked
with a shared `libiconv' which got broken as described above.
The fix is (1) remove `fk_ctype.o' from `libc.so'; (2) relink
`libiconv'.