https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126003
Alejandro Colomar <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |foss+gcc@alejandro-colomar. | |es --- Comment #4 from Alejandro Colomar <[email protected]> --- (In reply to Drea Pinski from comment #1) > Use -fsanitize=undefined. I'd like to avoid having to do that. It's nice that -fsanitize=undefined can catch these things at run time, but if we have the possibility of catching this at compile time, that'd be much better. If the amount of work to implement this is unreasonably high at the moment, I think it would be reasonable to close this as WONTFIX, but I'd recognize that as a goal, it would be good if GCC could eventually diagnose these things. I think closing it as INVALID is not appropriate. > twogig+twogig is only undefined if executed. We have plenty of UB that is diagnosed even if not executed, just because it is not known to not execute. > While TWOGIG+TWOGIG is considered as part of a constant integer expression > so it need to warn there. While the standard imposes a requirement that overflow is diagnosed in integer constant expressions, and doesn't impose the same in the case of regular arithmetic, it is expected that an implementation that is aware of the overflow would diagnose. The standard allows the existence of simpler implementations, but GCC is expected to be at the higher end of the quality range.
