https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112296
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |documentation CC| |jsm28 at gcc dot gnu.org, | |rth at gcc dot gnu.org --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- +FAIL: gcc.c-torture/execute/bcp-1.c -O1 (test for excess errors) +UNRESOLVED: gcc.c-torture/execute/bcp-1.c -O1 compilation failed to produce executable that's because bcp-1.c:(.text+0x6c): undefined reference to `func'^M collect2: error: ld returned 1 exit status^M the testcase can be reduced to int func(void); int bad7(void) { return __builtin_constant_p(func()); } and we want the side-effect to disappear!? There's more fun in this testcase, like verifying that int bad1(void) { return __builtin_constant_p(global++); } returns 0 (but not verifying whether 'global' is altered or not). I don't see it documented that __builtin_constant_p discards side-effects on operands - that would in fact make it behave like 'constexpr'?! commit 54303b5cb3076f7bae9102c08b59d57b1a9f5104 Author: Richard Henderson <r...@cygnus.com> Date: Tue Jul 7 06:41:17 1998 -0700 * gcc.c-torture/execute/bcp-1.c: New test. So this also becomes a documentation thing and I doubt we can start to retain side-effects we've thrown away for decades now. But then relying on _folding_ to implement what becomes a language extension this way is definitely error-prone and fragile. I think we should also definitely diagnose this somehow (which would also mean moving discarding of side-effects to the frontend(s)). Joseph, Richard, do you have anything to add or remember discussions about this semantic detail of __builtin_constant_p?