The preprocessor will ignore spaces between a backslash and a newline for continuation lines. This is in violation of C99, 5.1.1.2, # Each instance of a backslash character (\) immediately followed # by a new-line character is deleted As a result, a // comment ending in a backslash eats the next line. Release: 3.0 Environment: System: SunOS pandora 5.8 Generic_108528-06 sun4u sparc SUNW,Ultra-Enterprise Architecture: sun4 host: sparc-sun-solaris2.8 build: sparc-sun-solaris2.8 target: sparc-sun-solaris2.8 configured with: ../configure --enable-shared --enable-threads --with-cpu=v8 --with-gnu-ld --with-gnu-as --enable-version-specific-runtime-libs How-To-Repeat: /* Compile the following program with g++ -E. Notice the space after the backslash. */ // This is a single-line comment \ int i;
Fix: In cpplex.c:skip_escaped_newlines, rewrite the escape logic to not accept spaces immediately after the backslash, atleast not if in some strict mode.
From: "Joseph S. Myers" <jsm28@cam.ac.uk> To: <loewis@informatik.hu-berlin.de> Cc: <gcc-gnats@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org> Subject: Re: preprocessor/3786: cpp ignores space after backslash Date: Tue, 24 Jul 2001 10:33:55 +0100 (BST) On Tue, 24 Jul 2001 loewis@informatik.hu-berlin.de wrote: > The preprocessor will ignore spaces between a backslash and a newline > for continuation lines. This is in violation of C99, 5.1.1.2, > # Each instance of a backslash character (\) immediately followed > # by a new-line character is deleted > As a result, a // comment ending in a backslash eats the next line. This is part of the implementation-defined translation phase 1 mapping: invisible white space at the end of lines is ignored. There *is* a bug - that this feature ought to be mentioned under "Implementation-defined behavior" in the manual. -- Joseph S. Myers jsm28@cam.ac.uk
State-Changed-From-To: open->closed State-Changed-Why: Not a bug - this is documented behaviour in the manual.
Reopening to ...
Mark as a dup of bug 8270. *** This bug has been marked as a duplicate of 8270 ***