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

--- Comment #9 from Jonny Grant <jg at jguk dot org> ---
(In reply to Segher Boessenkool from comment #8)
> The C standard does not allow the line number (in a #line directive) to be
> smaller than 1 or bigger than 0x7fffffff.  It says nothing about actually
> having this many lines, or overflowing the line number with following lines,
> but I suppose we could disallow that as well.

int main(void)
{
#line 0
}

#1 with x86-64 gcc (trunk)
Compiler returned: 0

Maybe zero could be disallowed too.



> As the ICEs show many parts of GCC assume line numbers increase, so the
> wrap-around signed integer is a problem (it is anyway, it's UB in the
> compiler
> itself).  We could make the line number saturate, but this particular ICE
> won't
> go away unless line numbers are strictly increasing (or the code is changed).
> Changing the type to 64 bit won't help at all either, of course (we never
> actually see source files of 2G lines, already).

Not sure what is best here, I'm not knowledgeable of GCC, but maybe setting it
to -1 if it goes above, and then never increment again if(-1 == line) ...

Reply via email to