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

--- Comment #5 from Jonny Grant <jg at jguk dot org> ---
What appears to be a related issue. the "line number out of supported range"
does not show, even when gcc outputs a negative line number. Three test cases
below

I believe that the #line that pushes beyond 2^31  (The limit on my 64bit
machine) does not cause an error.  Only the #pragma message following does.

Just a note:
// 2^31 - 1.  Any more than this, and A1 overflows as "line3.c:-2147483648:9:
note: #pragma message: A1"
#line 2147483647

Anyway, the output

Current output from gcc trunk godbolt:

#1 with x86-64 gcc (trunk)
<source>: In function 'main':
<source>:-2147483647:9: note: #pragma message: B 
Compiler returned: 0


What I expected:
#1 with x86-64 gcc (trunk)
<source>: In function 'main':
<source>: warning: #line number 2147483649 out of supported range
<source>:-2147483647:9: note: #pragma message: B 
Compiler returned: 0


The program:
int main(void)
{
#line 2147483649
#pragma message "B "
}


It would be good if GCC could change to show the offending number, and write it
as #line. As GCC does in other output:

int main(void)
{
#line FOO
}


#1 with x86-64 gcc (trunk)
<source>: In function 'main':
<source>:3:7: error: "FOO" after #line is not a positive integer
    3 | #line FOO
      |       ^~~
Compiler returned: 1





Another program which does manage to show "warning: line number out of out of
supported range"



#1 with x86-64 gcc (trunk)
<source>: In function 'main':
<source>:3:7: warning: line number out of range
    3 | #line 112147483647
      |       ^~~~~~~~~~~~
Compiler returned: 0



int main(void)
{
#line 112147483647
}

Reply via email to