Bug 1228 - _GNU_SOURCE does not bring in C99 numeric limits
Summary: _GNU_SOURCE does not bring in C99 numeric limits
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.3.4
: P2 normal
Target Milestone: ---
Assignee: GOTO Masanori
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-22 21:08 UTC by Liviu Nicoara
Modified: 2018-04-19 14:52 UTC (History)
1 user (show)

See Also:
Host: i386-redhat-linux
Target: i386-redhat-linux
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Liviu Nicoara 2005-08-22 21:08:37 UTC
AFAIK, the following issue, although possibly known, has not been reported before. 

The following program:

$ cat t.c
#include <limits.h>

long long foo = LLONG_MAX;

compiles fine with:

$ gcc -std=c99 -c t.c

but fails to compile with:

$ gcc -D_GNU_SOURCE -c -v t.c
Reading specs from
/amd/packages/mdx/redhat/compilers/gcc-3.4.3-9.EL4/bin/../lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure
--prefix=/nfs/packages/mdx/rhas/compilers/gcc-3.4.3-9.EL4/
--mandir=/nfs/packages/mdx/rhas/compilers/gcc-3.4.3-9.EL4//man
--infodir=/nfs/packages/mdx/rhas/compilers/gcc-3.4.3-9.EL4//info --enable-shared
--enable-threads=posix --disable-checking --with-system-zlib
--enable-__cxa_atexit --disable-libunwind-exceptions
--enable-languages=c,c++,objc,java,f77 --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
 /amd/packages/mdx/redhat/compilers/gcc-3.4.3-9.EL4/bin/../libexec/gcc/i386-redhat-linux/3.4.3/cc1
-quiet -v -iprefix
/amd/packages/mdx/redhat/compilers/gcc-3.4.3-9.EL4/bin/../lib/gcc/i386-redhat-linux/3.4.3/
-D_GNU_SOURCE t.c -quiet -dumpbase t.c -auxbase t -version -o /tmp/cc2LZ5JU.s
ignoring nonexistent directory
"/amd/packages/mdx/redhat/compilers/gcc-3.4.3-9.EL4/bin/../lib/gcc/i386-redhat-linux/3.4.3/../../../../i386-redhat-linux/include"
ignoring nonexistent directory "/usr/local/include"
ignoring duplicate directory
"/nfs/packages/mdx/rhas/compilers/gcc-3.4.3-9.EL4//lib/gcc/i386-redhat-linux/3.4.3/include"
ignoring nonexistent directory
"/nfs/packages/mdx/rhas/compilers/gcc-3.4.3-9.EL4//lib/gcc/i386-redhat-linux/3.4.3/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /amd/packages/mdx/redhat/compilers/gcc-3.4.3-9.EL4/bin/../lib/gcc/i386-redhat-linux/3.4.3/include
 /nfs/packages/mdx/rhas/compilers/gcc-3.4.3-9.EL4//include
 /usr/include
End of search list.
GNU C version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4) (i386-redhat-linux)
        compiled by GNU C version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
t.c:3: error: `LLONG_MAX' undeclared here (not in a function)


The system (RH Advanced Server 4.0) is characterized by:

$ uname -a
Linux toque 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005 i686 i686 i386
GNU/Linux

$ /lib/libc.so.6 
GNU C Library stable release version 2.3.4, by Roland McGrath et al.
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4).
Compiled on a Linux 2.4.20 system on 2004-12-20.
.....

$ gcc -v
Reading specs from
/amd/packages/mdx/redhat/compilers/gcc-3.4.3-9.EL4/bin/../lib/gcc/i386-redhat-linux/3.4.3/specs
Configured with: ../configure
--prefix=/nfs/packages/mdx/rhas/compilers/gcc-3.4.3-9.EL4/
--mandir=/nfs/packages/mdx/rhas/compilers/gcc-3.4.3-9.EL4//man
--infodir=/nfs/packages/mdx/rhas/compilers/gcc-3.4.3-9.EL4//info --enable-shared
--enable-threads=posix --disable-checking --with-system-zlib
--enable-__cxa_atexit --disable-libunwind-exceptions
--enable-languages=c,c++,objc,java,f77 --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)

The same issue can be observed on other Linux systems we have: slackware (10.1),
suse (SLES 9), etc.

Aren't the libc C99 numeric limits supposed to be brought in by _GNU_SOURCE as
per the comment in features.h?

/* These are defined by the user (or the compiler)
   to specify the desired environment:

...............
   _ISOC99_SOURCE       Extensions to ISO C89 from ISO C99.
...............
   _GNU_SOURCE          All of the above, plus GNU extensions.
...............


Thanks,
Liviu
Comment 1 Ulrich Drepper 2005-10-16 15:33:27 UTC
Should be fixed in CVS.