https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81745
Bug ID: 81745 Summary: missing warning with -pedantic when a C file does not end with a newline character 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: --- The ISO C99 and C11 standards say in 5.1.1.2#2: "A source file that is not empty shall end in a new-line character". But the following doesn't generate any warning or error message: $ printf 'int main(void) { return 0; }' | gcc -xc -std=c99 -pedantic - $ with all the GCC versions I could test, including a 8.0.0 snapshot [trunk revision 250749]. Clang generates a warning (implied by -pedantic) as expected: $ printf 'int main(void) { return 0; }' | clang-4.0 -xc -std=c99 -pedantic - <stdin>:1:29: warning: no newline at end of file [-Wnewline-eof] int main(void) { return 0; } ^ 1 warning generated. $ GCC should do the same thing and use the same warning name -Wnewline-eof. Note: This bug is apparently a consequence of the fix of PR14331. In the bug report, it was asked for a new option, but the warning was suppressed unconditionally: https://gcc.gnu.org/viewcvs/gcc/trunk/libcpp/lex.c?r1=125212&r2=125211&pathrev=125212