Bug 15519 - preprocessor mistreats backslash-blank-newline in // comment
Summary: preprocessor mistreats backslash-blank-newline in // comment
Status: RESOLVED DUPLICATE of bug 8270
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-18 15:33 UTC by doug mcilroy
Modified: 2004-09-08 17:28 UTC (History)
1 user (show)

See Also:
Host: I can't guess what a "triplet" is
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-05-18 15:42:43


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description doug mcilroy 2004-05-18 15:33:21 UTC
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.
Comment 1 Andrew Pinski 2004-05-18 15:39:57 UTC
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
Comment 2 Andrew Pinski 2004-05-18 15:42:25 UTC
Woops I missed the sentence that says "remove the $ marks".
Comment 3 Zack Weinberg 2004-05-18 16:17:03 UTC
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
Comment 4 Andrew Pinski 2004-09-08 17:28:41 UTC
See 8270.

*** This bug has been marked as a duplicate of 8270 ***