https://gcc.gnu.org/bugzilla/show_bug.cgi?id=8270
Kai Tietz <ktietz at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ktietz at gcc dot gnu.org --- Comment #55 from Kai Tietz <ktietz at gcc dot gnu.org> --- Well, by looking into the standard ISO/IEC 9899:TC3 I found the following statement: 5.1.12 Translation phase "2. Each instance of a backslash character (\) immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. Only the last backslash on any physical source line shall be eligible for being part of such a splice. A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character before any such splicing takes place." For ISO/IEC 14882:2003 we see at topic "2 Lexical Convention" "2 Each instance of a new-line character and an immediately preceding backslash character is deleted, splicing physical source lines to form logical source lines. If, as a result, a character sequence that matches the syntax of a universal-character-name is produced, the behavior is undefined. If a source file that is not empty does not end in a new-line character, or ends in a new-line character immediately preceded by a backslash character, the behavior is undefined." So the handling of backslash whitespace newline is clearly a gnu-extension and not part of the standard. I suggest something like this patch for fixing standard-requirement. Additionally we could check here for cpp_option lang being gnu-style for allowing 'backslash,whitespaces,newling' too. Index: lex.c =================================================================== --- lex.c (Revision 221514) +++ lex.c (Arbeitskopie) @@ -896,6 +896,11 @@ _cpp_clean_line (cpp_reader *pfile) p--; if (p - 1 != pbackslash) goto done; + if (p != d) + { + ++p; + goto done; + } /* Have an escaped newline; process it and proceed to the slow path. */ @@ -917,13 +922,19 @@ _cpp_clean_line (cpp_reader *pfile) if (s == buffer->rlimit) break; - /* Escaped? */ + /* Escaped? + But make sure it isn't a backslash followed by a + whitespace. */ p = d; while (p != buffer->next_line && is_nvspace (p[-1])) p--; if (p == buffer->next_line || p[-1] != '\\') break; - + if (p != d) + { + ++p; + break; + } add_line_note (buffer, p - 1, p != d ? ' ': '\\'); d = p - 2; buffer->next_line = p - 1;