Bug#539912: gcc-4.3: POSIX requires that option -D have a lower precedence than -U
Package: gcc-4.3
Version: 4.3.3-15
Severity: normal
Note: this is a bug concerning the c99 utility, but since c99 uses
gcc, I report the bug against gcc. Also note that both gcc-4.4 and
gcc-snapshot have the same problem. I've also reported the bug on
GCC's bugzilla: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40960
In http://www.opengroup.org/onlinepubs/9699919799/utilities/c99.html
POSIX specifies:
-D name[=value]
Define name as if by a C-language #define directive. If no = value
is given, a value of 1 shall be used. The -D option has lower
precedence than the -U option. That is, if name is used in both a
-U and a -D option, name shall be undefined regardless of the
order of the options.
However, gcc doesn't take the precedence rule into account:
$ cat tst.c
int main(void)
{
#ifdef FOO
return 1;
#else
return 0;
#endif
}
$ c99 tst.c -UFOO -DFOO=1
$ ./a.out
zsh: exit 1 ./a.out
whereas FOO should be undefined and the return value should be 0, not 1.
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.30-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.ISO8859-1 (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash
Versions of packages gcc-4.3 depends on:
ii binutils 2.19.51.20090723-1 The GNU assembler, linker and bina
ii cpp-4.3 4.3.3-15 The GNU C preprocessor
ii gcc-4.3-base 4.3.3-15 The GNU Compiler Collection (base
ii libc6 2.9-23 GNU C Library: Shared libraries
ii libgcc1 1:4.4.1-1 GCC support library
ii libgomp1 4.4.1-1 GCC OpenMP (GOMP) support library
Versions of packages gcc-4.3 recommends:
ii libc6-dev 2.9-23 GNU C Library: Development Librari
Versions of packages gcc-4.3 suggests:
ii gcc-4.3-doc 4.3.2.nf1-1 documentation for the GNU compiler
pn gcc-4.3-locales <none> (no description available)
pn gcc-4.3-multilib <none> (no description available)
pn libgcc1-dbg <none> (no description available)
pn libgomp1-dbg <none> (no description available)
pn libmudflap0-4.3-dev <none> (no description available)
pn libmudflap0-dbg <none> (no description available)
-- no debconf information
Reply to: