This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/4022] New: wchar.h is broken when gcc 4.3 is used with option --std=gnu99


Applies to glibc-2.3.x to 2.5 (but the bugtracker does not have a combobox entry
for glibc-2.5).

The gcc 4.3 development branch apparently implements 'inline' more closely to
ISO C 99, when --std=gnu99 is used. Use of <wchar.h> in at least two compilation
units leads to link errors:

$ gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.3-20070209/configure
--prefix=/house/bhaible2/prefix-linux-x86_64/gnu-inst-gcc/4.3-20070209
--enable-shared --enable-version-specific-runtime-libs --enable-threads=posix
--enable-__cxa_atexit
Thread model: posix
gcc version 4.3.0 20070209 (experimental)

$ cat foo1.c
#include <wchar.h>
extern int zero (void);
int main () { return zero(); }
$ cat foo2.c
#include <wchar.h>
int zero (void) { return 0; }
$ gcc -static --std=gnu99 -O2 -Wall foo1.c foo2.c 
/tmp/cc0muMOp.o: In function `wcstoul':
foo2.c:(.text+0x10): multiple definition of `wcstoul'
/tmp/ccMA19co.o:foo1.c:(.text+0x10): first defined here
/tmp/cc0muMOp.o: In function `wcstol':
foo2.c:(.text+0x20): multiple definition of `wcstol'
/tmp/ccMA19co.o:foo1.c:(.text+0x20): first defined here
/tmp/cc0muMOp.o: In function `wcstod':
foo2.c:(.text+0x30): multiple definition of `wcstod'
/tmp/ccMA19co.o:foo1.c:(.text+0x30): first defined here
/usr/lib/../lib64/libc.a(wcstol.o): In function `wcstoq':
(.text+0x10): multiple definition of `wcstol'
/tmp/ccMA19co.o:foo1.c:(.text+0x20): first defined here
/usr/bin/ld: Warning: size of symbol `wcstol' changed from 7 in /tmp/ccMA19co.o
to 18 in /usr/lib/../lib64/libc.a(wcstol.o)
/usr/lib/../lib64/libc.a(wcstoul.o): In function `wcstouq':
(.text+0x10): multiple definition of `wcstoul'
/tmp/ccMA19co.o:foo1.c:(.text+0x10): first defined here
/usr/bin/ld: Warning: size of symbol `wcstoul' changed from 7 in /tmp/ccMA19co.o
to 18 in /usr/lib/../lib64/libc.a(wcstoul.o)
collect2: ld returned 1 exit status

Look closer what's happening:

$ gcc --std=gnu99 -O2 -c foo2.c
$ nm foo2.o
                 U __wcstod_internal
                 U __wcstol_internal
                 U __wcstoul_internal
0000000000000030 T wcstod
0000000000000020 T wcstol
0000000000000010 T wcstoul
0000000000000000 T zero

The inclusion of <wchar.h> causes the compilation unit to export wcstoul etc.
(on 32-bit platforms also wcstouq etc.). The reason is that these functions
are
  - first declared as "extern",
  - then defined as "extern __inline",
This combination causes the functiona to be exported according to the rules of
ISO C 99. For more details about the semantics of "inline" and the earlier
gcc semantics, see
  http://lists.gnu.org/archive/html/bug-gnulib/2006-11/msg00055.html

-- 
           Summary: wchar.h is broken when gcc 4.3 is used with option --
                    std=gnu99
           Product: glibc
           Version: 2.4
            Status: NEW
          Severity: critical
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: bruno at clisp dot org
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=4022

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]