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.
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.
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.
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>)?
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.
*** Bug 11806 has been marked as a duplicate of this bug. ***
*** Bug 12075 has been marked as a duplicate of this bug. ***
*** Bug 15688 has been marked as a duplicate of this bug. ***
*** Bug 102790 has been marked as a duplicate of this bug. ***