#539912 gcc-*: for c99, POSIX requires that option -D have a lower precedence than -U

Package:
gcc-11
Source:
gcc-11
Description:
GNU C compiler
Submitter:
Vincent Lefevre
Date:
2021-12-28 09:24:05 UTC
Severity:
normal
Tags:
#539912#5
Date:
2009-08-04 11:53:21 UTC
From:
To:
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.

#539912#10
Date:
2016-06-17 22:52:54 UTC
From:
To:
This bug has been reported against an ancient version of
gpc (4.1), gcc/g++/gfortran (4.3), or gcj/gij/gobjc (4.4), that was last
released with Debian 6.0 (squeeze). But even squeeze-lts has now reached
end-of-life and is no longer supported.
The bug is assumed to be fixed (or no longer relevant) in newer GCC
releases and therefore I'm closing this report now. If the problem is
still reproducible in the currently supported versions (gcc-5, gcc-6 or
corresponding g++/gcj), feel free to provide more information, reopen
and reassign this bug report.


Andreas

#539912#15
Date:
2016-06-18 23:36:28 UTC
From:
To:
This bug still occurs with gcc-5.
#539912#34
Date:
2016-08-08 15:38:52 UTC
From:
To:
as this is now the default compiler, and the bug still occurs with it.
#539912#47
Date:
2019-02-07 03:13:19 UTC
From:
To:
Dear submitter,

as the package gcc-6 has just been removed from the Debian archive
unstable we hereby close the associated bug reports.  We are sorry
that we couldn't deal with your issue properly.

For details on the removal, please see https://bugs.debian.org/920171

The version of this package that was in Debian prior to this removal
can still be found using http://snapshot.debian.org/.

This message was generated automatically; if you believe that there is
a problem with it please contact the archive administrators by mailing
ftpmaster@ftp-master.debian.org.

Debian distribution maintenance software
pp.
Scott Kitterman (the ftpmaster behind the curtain)

#539912#52
Date:
2019-02-07 08:27:12 UTC
From:
To:
as this is now the default compiler, and the bug still occurs with it.
#539912#69
Date:
2021-02-13 13:07:12 UTC
From:
To:
Dear submitter,

as the package gcc-8 has just been removed from the Debian archive
unstable we hereby close the associated bug reports.  We are sorry
that we couldn't deal with your issue properly.

For details on the removal, please see https://bugs.debian.org/954831

The version of this package that was in Debian prior to this removal
can still be found using http://snapshot.debian.org/.

Please note that the changes have been done on the master archive and
will not propagate to any mirrors until the next dinstall run at the
earliest.

This message was generated automatically; if you believe that there is
a problem with it please contact the archive administrators by mailing
ftpmaster@ftp-master.debian.org.

Debian distribution maintenance software
pp.
Joerg Jaspert (the ftpmaster behind the curtain)

#539912#74
Date:
2021-02-13 17:33:35 UTC
From:
To:
Still occurs there, which is now the default gcc.
#539912#91
Date:
2021-12-28 08:50:27 UTC
From:
To:
I am Lynn NaffI' from USA. I want us to be good friends. I have some very
important things to talk to you. (lynnnaff995@gmail.com) so we can
talk more and also send my photos, I wait to hear from you

#539912#96
Date:
2021-12-28 09:15:30 UTC
From:
To:
Reopen bug closed by a spammer.
#539912#103
Date:
2021-12-28 09:21:04 UTC
From:
To:
since the gcc package now depends on gcc-11 and the bug is still
present.