https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97602

            Bug ID: 97602
           Summary: #line overflow check incomplete
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jsm28 at gcc dot gnu.org
  Target Milestone: ---

Preprocessing the following test with -pedantic does not produce a diagnostic,
just silent wrapping of the line number.

#line 5000000000

By comparison, if you instead have

#line 3000000000

then you get a diagnostic

t.c:1:7: warning: line number out of range
    1 | #line 3000000000
      |       ^~~~~~~~~~

The code in directives.c:strtolinenum tries to check for overflow after it
occurs, with logic "if (reg < reg_prev)" that doesn't cover all cases. 
Checking before it occurs (allowing properly for the case of UINT_MAX / 10
where overflow depends on the value of the next digit) is needed instead.

Reply via email to