https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81746
Bug ID: 81746 Summary: a blackslash at the end of a file is not removed Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: vincent-gcc at vinc17 dot net Target Milestone: --- According to https://gcc.gnu.org/ml/gcc-patches/2007-04/msg00504.html each input file is defined "to end with a newline, whether or not the actual physical Unix input file did so". This is why the following works: $ printf '#define FOO' | gcc -E - # 1 "<stdin>" # 1 "<built-in>" # 1 "<command-line>" # 31 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 32 "<command-line>" 2 # 1 "<stdin>" $ and $ printf 'int main(void) { return 0; } //' | gcc -E - # 1 "<stdin>" # 1 "<built-in>" # 1 "<command-line>" # 31 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 32 "<command-line>" 2 # 1 "<stdin>" int main(void) { return 0; } $ But the following doesn't work: $ printf 'int main(void) { return 0; } \\' | gcc -E - # 1 "<stdin>" # 1 "<built-in>" # 1 "<command-line>" # 31 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 32 "<command-line>" 2 # 1 "<stdin>" int main(void) { return 0; } \ $ The backslash should have been removed, just like "//" was removed above. This yields an error if there is no explicit newline character at the end of the physical Unix input file: $ printf 'int main(void) { return 0; } \\' | gcc -xc -std=c99 - && echo OK <stdin>:1:30: error: stray ‘\’ in program $ printf 'int main(void) { return 0; } \\\n' | gcc -xc -std=c99 - && echo OK <stdin>:1:30: warning: backslash-newline at end of file OK $