In both 3.3.1 (cygwin, NT) and 3.2.2 (redhat, linux) the preprocessor silently--and wrongly--eats the declaration below, where $ marks have been placed to show the end of lines. The comment was carefully written to avoid the very misbehavior that it elicited. To exhibit the trouble, remove the $ marks and compile with g++ -pedantic -E // boolean operation /\ $ extern int band(int,int);$ In some contexts g++ warns of the presence of backslash-space-newline, but not in comments. Under option -Wall, it reports a "multiline comment". The warnings do not, however, point out that the g++ interpretation is nonstandard, even in -pedantic mode.
I cannot reproduce this with released versions of 3.2.2, 3.2.3, 3.3.3, or 3.4.0 (or the mainline of gcc). Are you sure that you can reproduce it with the given example. I get for 3.3.x and below: pr15519.cc:3: syntax error at end of input For 3.4.0 and above: pr15519.cc:2: error: expected constructor, destructor, or type conversion at end of input pr15519.cc:2: error: expected `,' or `;' at end of input
Woops I missed the sentence that says "remove the $ marks".
Subject: Re: New: preprocessor mistreats backslash-blank-newline in // comment "doug at cs dot dartmouth dot edu" <gcc-bugzilla@gcc.gnu.org> writes: > // boolean operation /\ $ > extern int band(int,int);$ > > In some contexts g++ warns of the presence of backslash-space-newline, > but not in comments. Under option -Wall, it reports a "multiline > comment". The warnings do not, however, point out that the g++ > interpretation is nonstandard, even in -pedantic mode. That's because it isn't nonstandard. It's the mapping of "end-of-line indicators" in translation phase 1 (C99 5.1.1.2) - Physical source file multibyte characters are mapped, in an implementation-defined manner, to the source character set (introducing new-line characters for end-of-line indicators) The term "end-of-line indicator" is defined in section 5.2.1 as "In source files, there shall be some way of indicating the end of each line of text" - i.e. it's implementation-defined. GCC's definition of an end-of-line indicator is "any number of horizontal whitespace characters (space \t \v \f) followed by \n, \r\n, or \r". Identical text to C99 5.1.1.2 appears in C++98 section 2.1 [lex.phases] - there doesn't seem to be a definition of "end-of-line indicator" at all. --- So, no, we're not going to make -pedantic care about this. However, a patch to make the backslash-space-newline warning trigger within comments when it will change the meaning of the program (and ONLY then) would be welcome. Alternatively, the "multiline comment" warning could be turned on by default. zw
See 8270. *** This bug has been marked as a duplicate of 8270 ***