https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84864
Bug ID: 84864 Summary: Issues with large line numbers >= 2^31 Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: deferred, diagnostic Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Target Milestone: --- PR 84852 describes an ICE on this source code: $ cat test.c #line 7777777777 int foo (void) { return strlen(""); } On fixing the ICE, the #line directive leads to negative line numbers, with the diagnostic reported here: test.c:-812156815:25: The 7777777777 is truncated to unsigned 32 bits (linenum_type), from 0x1cf977871 to 0xcf977871 == 3482810481. In some places we use linenum_type (unsigned int); in others we use int, leading to the printing of -812156815 for the line number. We already warn for too-large line numbers with -pedantic: test.c:1:7: warning: line number out of range #line 7777777777 ^~~~~~~~~~ There seem to be at least two issues here: * silent truncation of #line * use of negative numbers for such cases I experimented with using linenum_type throughout for the fix for PR 84852, but it was more invasive that I'd have liked in stage 4, so filing this to track addressing this when stage 1 opens.