Bug 11064 - Preprocessor tries to tokenize code that should be unconditionally skipped
Summary: Preprocessor tries to tokenize code that should be unconditionally skipped
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 11806 12075 15688 102790 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-06-02 13:16 UTC by Robert Schiele
Modified: 2022-12-08 12:19 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Schiele 2003-06-02 13:16:15 UTC
gcc tries to tokenize code that is wrapped around with #if 0 ... #endif 
 
Try compiling the following code: 
 
#if 0 
" 
#endif 
 
Although the quotes are no valid C token, to my opinion the compiler should not care about it, 
as the section should be completely skipped by the preprocessor. But in fact, the compiler 
teminates by the message 
 
missing terminating " character 
 
gcc 3.4 behaves in a sane way here.
Comment 1 Andrew Pinski 2003-06-02 14:04:03 UTC
This is not a bug, the ISO/ANSI C says they have be tokens inside the #if ... #endif blocks, 
even if it is #if 0 ... #endif.
Comment 2 Neil Booth 2003-06-02 19:44:24 UTC
Subject: Re:  Preprocessor tries to tokenize code that should be unconditionally skipped

pinskia@physics.uc.edu wrote:-

> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11064
> 
> 
> pinskia@physics.uc.edu changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>              Status|UNCONFIRMED                 |RESOLVED
>          Resolution|                            |INVALID
> 
> 
> ------- Additional Comments From pinskia@physics.uc.edu  2003-06-02 14:04 -------
> This is not a bug, the ISO/ANSI C says they have be tokens inside the #if ... #endif blocks, 
> even if it is #if 0 ... #endif.

Yes, but it leaves tokenization in the case of unterminated quotes to
the implementation, so we can do either.  As the reporter ovserved, 3.4
accepts the code.  3.3 won't change.

Neil.
Comment 3 Joseph S. Myers 2003-06-02 19:51:44 UTC
Subject: Re:  Preprocessor tries to tokenize code
 that should be unconditionally skipped

On Mon, 2 Jun 2003, neil@daikokuya.co.uk wrote:

> Yes, but it leaves tokenization in the case of unterminated quotes to
> the implementation, so we can do either.  As the reporter ovserved, 3.4
> accepts the code.  3.3 won't change.

Does 3.4 (a) properly warn for unportable code that has unterminated
quotes (in preprocessing tokens that are not converted to tokens) and (b)  
document these extensions (I didn't see any response to
<http://gcc.gnu.org/ml/gcc-patches/2003-04/msg01855.html>)?

Comment 4 Robert Schiele 2003-06-02 20:03:33 UTC
Neil: I do not have a strong opinion about the issue. As the standard forces to have valid 
tokens there, it is ok for me. Just didn't know about this constraint before. 
 
Joseph: No, 3.4 does not warn, even not with -W -Wall -pedantic. 
Comment 5 Andrew Pinski 2021-10-15 20:21:31 UTC
*** Bug 11806 has been marked as a duplicate of this bug. ***
Comment 6 Andrew Pinski 2021-10-15 20:22:36 UTC
*** Bug 12075 has been marked as a duplicate of this bug. ***
Comment 7 Andrew Pinski 2021-10-15 20:23:31 UTC
*** Bug 15688 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2021-10-15 20:23:47 UTC
*** Bug 102790 has been marked as a duplicate of this bug. ***