https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79482
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-02-20
CC| |msebor at gcc dot gnu.org
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=79648
Ever confirmed|0 |1
--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed with the top of trunk.
It's probably related to bug 65656 one way or the other though I don't think
it's exactly the same thing. The C and C++ front ends handle constant
expressions differently. The C test case in this bug can be reduced to the
following C/C++ test case. It fails with the C front end but succeeds with the
C++ front end. See also bug 79648 for a different variation on this test case.
$ (set -x && cat t.c && for lang in c c++; do for o in 0 2; do gcc -O$o -S
-Wall -Wunused -Wpedantic -x$lang t.c; done; done)
+ cat t.c
void f (void)
{
int x = 0;
enum { b = __builtin_constant_p (x) ? 1 : 2 };
}
+ for lang in c c++
+ for o in 0 2
+ /build/gcc-git/gcc/xgcc -B /build/gcc-git/gcc -O0 -S -Wall -Wunused
-Wpedantic -xc t.c
+ for o in 0 2
+ /build/gcc-git/gcc/xgcc -B /build/gcc-git/gcc -O2 -S -Wall -Wunused
-Wpedantic -xc t.c
t.c: In function ‘f’:
t.c:5:10: error: enumerator value for ‘b’ is not an integer constant
enum { b = __builtin_constant_p (x) ? 1 : 2 };
^
+ for lang in c c++
+ for o in 0 2
+ /build/gcc-git/gcc/xgcc -B /build/gcc-git/gcc -O0 -S -Wall -Wunused
-Wpedantic -xc++ t.c
+ for o in 0 2
+ /build/gcc-git/gcc/xgcc -B /build/gcc-git/gcc -O2 -S -Wall -Wunused
-Wpedantic -xc++ t.c