On 2021-04-16 14:52:50 +0100, Edmund Grimley Evans wrote: > Riddle me this: > > $ gcc --version | head -n 1 > gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 > $ printf '#line 60129542143\n__LINE__' | gcc -E - | grep -v ^# > 4294967295 > $ printf '#line 60129542144\n__LINE__' | gcc -E - | grep -v ^# > <stdin>:1:7: warning: line number out of range > 0 > $ gdb > (gdb) p/x 60129542143 > $1 = 0xdffffffff > (gdb)
Well, providing a #line value larger than the maximum allowed by the C standard is undefined behavior, and a diagnostic is not required because this is not a constraint here. But here, this is probably a bug in GCC. $ printf '#line 4294967296\n__LINE__' | gcc -E - | grep -v "^#" <stdin>:1:7: warning: line number out of range 0 $ printf '#line 8589934591\n__LINE__' | gcc -E - | grep -v "^#" 4294967295 $ printf '#line 8589934592\n__LINE__' | gcc -E - | grep -v "^#" <stdin>:1:7: warning: line number out of range 0 I suspect that some bound test may be wrong. For instance, it correctly detects the issue when converted to int, it gives a nonnegative value, but not for negative values (and the output seems to be done with an unsigned int). -- Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) _______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
