https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126003
--- Comment #10 from Alejandro Colomar <[email protected]> --- (In reply to Drea Pinski from comment #9) > (In reply to Alejandro Colomar from comment #5) > > (In reply to Drea Pinski from comment #1) > > > twogig+twogig is only undefined if executed. > > > While TWOGIG+TWOGIG is considered as part of a constant integer expression > > > so it need to warn there. > > > > This is not correct. TL;DR: Both of them only have UB if executed, and > > none of them violate any constraints. See below. > > > > CC += Joseph > > > > TWOGIG+TWOGIG, by being part of an argument to a function, is not a constant > > expression. > > Huh? Read the original source again? `TWOGIG+TWOGIG` is not part of the > argument of a function but rather part of the initialization of a global > scoped variable. Sorry, I was referring to the second program.= This line of code: printf("%d\n",TWOGIG+TWOGIG); // evaluated under -O0 doesn't contain constant expressions. I quoted a wrong line from you. But this still shows that the reason for closing as invalid was not valid (at least after the second example was shown). (In reply to Drea Pinski from comment #8) > (In reply to Alejandro Colomar from comment #7) > > (In reply to Joseph S. Myers from comment #6) > > > That's the distinction between pedwarns for overflow, in contexts where a > > > constant expression is required, and warnings, in contexts where one isn't > > > but an expression with constant operands would overflow and produce UB at > > > runtime if evaluated. > > > > Should the bug be reopened? I don't think it's invalid; or at least, the > > reasons given for considering it invalid are not technically correct. > > No because there is no way to figure at compile time (in the front-end) that > twogig+twogig would overflow. It is only happens during the middle-end. > Which we are not going to add a warning for; we just removed the warning > overflow related stuff. I agree about this part. That's why I think this should be closed as WONTFIX, and not as INVALID.
