This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
preprocessor/7962: -traditional's handling of unbalanced " in unused #if blocks
- From: mrs at apple dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 18 Sep 2002 05:46:52 -0000
- Subject: preprocessor/7962: -traditional's handling of unbalanced " in unused #if blocks
- Reply-to: mrs at apple dot com
>Number: 7962
>Category: preprocessor
>Synopsis: -traditional's handling of unbalanced " in unused #if blocks
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Sep 17 22:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: mrs@apple.com
>Release: version 3.1 20020420
>Organization:
>Environment:
>Description:
If one compiles the enclosed file with -traditional-cpp, the program will return with 1, if compiled with the other cpp, it returns 0, the correct value. To understand why, examine the output of -E between the two and look for case 1:
ash-2.05a$ gcc t3.c -traditional-cpp -E | grep case
t3.c:15:40: warning: multi-line string literals are deprecated
case 0:
case 2:
bash-2.05a$ gcc t3.c -E | grep case
case 0 :
case 1 :
case 2 :
:-( Very confusing to people that `know' that the insides of unused #if blocks are totally discarded.
Radar 2404967
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="trad.c"
Content-Disposition: inline; filename="trad.c"
/* Compile with -traditional-cpp to show bug. */
#define NOCOPY 0
#include <stdio.h>
int
main()
{
int dummy =0;
switch (1) {
case 0:
#if NOCOPY
if (dummy) panic(swprint: bad dummy"); /* XXX */
#endif NOCOPY
break;
case 1:
#if NOCOPY
if (dummy) panic(swprint: bad dummy"); /* XXX */
#endif NOCOPY
return 0;
case 2:
#if NOCOPY
if (dummy) panic("swprint: bad dummy");
#endif NOCOPY
break;
default:
return 1;
}
}