public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* preprocessor/7962: -traditional's handling of unbalanced " in unused #if blocks
@ 2002-09-17 22:56 mrs
0 siblings, 0 replies; 5+ messages in thread
From: mrs @ 2002-09-17 22:56 UTC (permalink / raw)
To: gcc-gnats
>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;
}
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: preprocessor/7962: -traditional's handling of unbalanced " in unused #if blocks
@ 2002-09-18 3:19 neil
0 siblings, 0 replies; 5+ messages in thread
From: neil @ 2002-09-18 3:19 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, mrs, nobody
Synopsis: -traditional's handling of unbalanced " in unused #if blocks
State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Wed Sep 18 03:19:40 2002
State-Changed-Why:
Mistaken, as discussed.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7962
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: preprocessor/7962: -traditional's handling of unbalanced " in unused #if blocks
@ 2002-09-18 0:56 Neil Booth
0 siblings, 0 replies; 5+ messages in thread
From: Neil Booth @ 2002-09-18 0:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/7962; it has been noted by GNATS.
From: Neil Booth <neil@daikokuya.co.uk>
To: mrs@apple.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: preprocessor/7962: -traditional's handling of unbalanced " in unused #if blocks
Date: Wed, 18 Sep 2002 08:50:11 +0100
mrs@apple.com wrote:-
> 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:
Hmm. tradcpp.c doesn't even have this error message so I'm confused.
You're clearly using the ISO preprocessor somehow or other.
How is cpp or tradcpp invoked if you specify -v?
> bash-2.05a$ gcc t3.c -E | grep case
> case 0 :
> case 1 :
> case 2 :
I find this hard to believe too: it looks like this is going through
tradcpp rather than CPP, as CPP will warn about multi-line deprecation
and would have sucked up case 1 in the first multi-line literal.
-v please.
Are you sure Apple hasn't removed a "!" from specs by accident?
> :-( Very confusing to people that `know' that the insides of unused #if blocks are totally discarded.
I am indeed confused. I don't have a 3.1/3.2 binary around, but I can say
it works in HEAD (3.3).
Sceptically,
Neil.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: preprocessor/7962: -traditional's handling of unbalanced " in unused #if blocks
@ 2002-09-18 0:46 Mike Stump
0 siblings, 0 replies; 5+ messages in thread
From: Mike Stump @ 2002-09-18 0:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/7962; it has been noted by GNATS.
From: Mike Stump <mrs@apple.com>
To: Zack Weinberg <zack@codesourcery.com>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: preprocessor/7962: -traditional's handling of unbalanced " in unused #if blocks
Date: Wed, 18 Sep 2002 00:41:00 -0700
On Tuesday, September 17, 2002, at 11:17 PM, Zack Weinberg wrote:
> In 3.3 all the case statements survive in both modes, but the
> translation unit is rejected without -traditional-cpp.
Sorry for the bug report. I can confirm that gcc now does exactly what
was desired.
The report can be closed.
:-(
multiline strings are evil!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: preprocessor/7962: -traditional's handling of unbalanced " in unused #if blocks
@ 2002-09-17 23:26 Zack Weinberg
0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2002-09-17 23:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/7962; it has been noted by GNATS.
From: Zack Weinberg <zack@codesourcery.com>
To: mrs@apple.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: preprocessor/7962: -traditional's handling of unbalanced " in unused #if blocks
Date: Tue, 17 Sep 2002 23:17:50 -0700
On Wed, Sep 18, 2002 at 05:46:52AM -0000, mrs@apple.com wrote:
> 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 :
Odd; my testing indicates precisely the opposite effect, with both
2.95 and 3.2.
$ gcc-2.95 -traditional-cpp -E test.c | grep case
case 0:
case 1:
case 2:
$ gcc-2.95 -E test.c | grep case
case 0:
case 2:
$ gcc-3.2 -traditional-cpp -E test.c | grep case
case 0:
case 1:
case 2:
$ gcc-3.2 -E test.c | grep case
test.c:15:40: warning: multi-line string literals are deprecated
test.c:22:8: warning: extra tokens at end of #endif directive
test.c:28:8: warning: extra tokens at end of #endif directive
case 0:
case 2:
In 3.3 all the case statements survive in both modes, but the
translation unit is rejected without -traditional-cpp.
$ ./xgcc -B./ -traditional-cpp -E test.c | grep case
test.c:16: warning: extra tokens at end of #endif directive
test.c:22: warning: extra tokens at end of #endif directive
test.c:28: warning: extra tokens at end of #endif directive
case 0:
case 1:
case 2:
$ ./xgcc -B./ -E test.c | grep case
test.c:15:40: missing terminating " character
test.c:16:8: warning: extra tokens at end of #endif directive
test.c:21:40: missing terminating " character
test.c:22:8: warning: extra tokens at end of #endif directive
test.c:28:8: warning: extra tokens at end of #endif directive
case 0:
case 1:
case 2:
The reason for the effect as I see it is quite clear - up to 2.2,
multiline strings exist, so everything from the first panic() to the
second, including the first #endif, the missing case statement, and
the next #if NOCOPY, is absorbed into the string constant. The entire
thing is then thrown away because it's inside a failed conditional
block (extending from the first #if NOCOPY to the _second_ #endif).
In traditional mode, however, strings silently end at the end of the
line ("a workaround for not knowing comment boundaries when
-traditional is used to preprocess things which are not C", to
paraphrase the manual) so all three #endif-s are honored. And in 3.3,
there are no multiline strings, so the same thing happens without
-traditional-cpp.
I don't see how you got the effect you described, nor do I see what
you want changed. Please clarify.
zw
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-09-18 10:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-17 22:56 preprocessor/7962: -traditional's handling of unbalanced " in unused #if blocks mrs
2002-09-17 23:26 Zack Weinberg
2002-09-18 0:46 Mike Stump
2002-09-18 0:56 Neil Booth
2002-09-18 3:19 neil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).