preprocessor/818: With -O2, preprocessor gives fatal error
psmith@gnu.org
psmith@gnu.org
Wed Nov 15 14:46:00 GMT 2000
>Number: 818
>Category: preprocessor
>Synopsis: With -O2, preprocessor gives fatal error
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Nov 15 14:46:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator: Paul D. Smith
>Release: GCC 2.95.2
>Organization:
>Environment:
Debian GNU/Linux 2.2+woody
GLIBC 2.1.95-1
>Description:
With the simple C code below, building without optimization:
$ gcc -o ifdef.o -c ifdef.c
$
With -O2:
$ gcc -O2 -o ifdef.o -c ifdef.c
ifdef.c:14: warning: preprocessing directive not recognized within macro arg
ifdef.c:14: warning: preprocessing directive not recognized within macro arg
ifdef.c:14: warning: preprocessing directive not recognized within macro arg
ifdef.c: In function `foo_bar':
ifdef.c:9: undefined or invalid # directive
ifdef.c:11: undefined or invalid # directive
ifdef.c:12: parse error before `2'
ifdef.c:13: undefined or invalid # directive
ifdef.c:14: parse error before `#'
ifdef.c:14: `cray' undeclared (first use in this function)
ifdef.c:14: (Each undeclared identifier is reported only once
ifdef.c:14: for each function it appears in.)
ifdef.c:14: parse error before `1'
ifdef.c:14: parse error before `#'
ifdef.c:14: parse error before `1'
ifdef.c:14: parse error before `)'
ifdef.c:14: `__s1_len' undeclared (first use in this function)
ifdef.c:14: `__s2_len' undeclared (first use in this function)
ifdef.c: At top level:
ifdef.c:14: parse error before `)'
>How-To-Repeat:
Repeatable.
>Fix:
Workaround:
If I change the ifdefs to appear outside of the strncmp()
it works. Apparently with optimization on the strncmp()
is expanded into inline code, and for some reason the
preprocessor doesn't resolve the conditionals appearing
within the function arguments _before_ that happens.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="ifdef.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="ifdef.c"
I2luY2x1ZGUgPHN0cmluZy5oPgoKaW50CmZvb19iYXIobmFtZSwgbWVtKQogIGNoYXIgKm5hbWUs
ICptZW07CnsKICAgICAgcmV0dXJuICFzdHJuY21wIChuYW1lLCBtZW0sCgkJICAgICAgIDEwIC0K
I2lmICFkZWZpbmVkIChfX2hwdXgpICYmICFkZWZpbmVkIChjcmF5KQoJCSAgICAgICAxCiNlbHNl
CgkJICAgICAgIDIKI2VuZGlmCgkJICAgICAgICk7Cn0K
More information about the Gcc-bugs
mailing list