Preprocessing this: #line 12312312312435 produces: # 2936042099 ".../foo.c" C99 specifies that the argument to #line shall be > 0 and < 2^31-1, and even if it didn't, truncation like this should at least be warned about. -Chris
[kudzu:~] pinskia% gcc t.c -pedantic-errors -std=c99 t.c:1:7: error: line number out of range t.c:-1358925197: error: ISO C forbids an empty source file With -pedantic we just get a warning. I don't know if we should warn even with -pedantic.
Tom, as the libcpp maintainer, could you give your opinion about this? I personally think a warning could be useful, it may point out some bug in an auto-generated file. Moreover, I think that the standard also require us to warn (with -pedantic) for the wrapping case.
Also, I noticed that there is an implicit conversion from ulong to uint when calling _cpp_do_file_change in do_linemarker. That is the point where the truncation takes place.
Sorry for the delay on this. I never remember our rules about when to emit pedantic warnings and the like. I think libcpp should follow the overall gcc approach here, whatever that is. I agree that warning about truncation is a good idea. Silently doing the wrong thing is unfriendly.
I don't see why this should be marked "wait". Changing back to "new".
Subject: Bug 28079 Author: manu Date: Tue Jul 22 09:45:58 2008 New Revision: 138049 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=138049 Log: 2008-07-22 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR 28079 libcpp/ * directives.c (strtolinenum): Handle overflow. (do_line): Give a warning if line number overflowed. (do_linemarker): Update call to strtolinenum. gcc/testsuite/ * gcc.dg/cpp/line6.c: New. Added: trunk/gcc/testsuite/gcc.dg/cpp/line6.c Modified: trunk/gcc/testsuite/ChangeLog trunk/libcpp/ChangeLog trunk/libcpp/directives.c
Fixed in GCC 4.4