Bug 56759 - result of __builtin_constant_p( ) is not constant enough for __builtin_choose_expr( )
Summary: result of __builtin_constant_p( ) is not constant enough for __builtin_choose...
Status: RESOLVED DUPLICATE of bug 19449
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.8.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-28 00:55 UTC by Cody P Schafer
Modified: 2013-03-28 06:57 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cody P Schafer 2013-03-28 00:55:12 UTC
Testcase:
---
static inline int x(int y)
{
	return __builtin_choose_expr(__builtin_constant_p(y), 1, 0);
}

int foo(void)
{
	return x(3);
}
---


$ i386-linux-gcc constant_not_constant.c  -O3 -c
constant_not_constant.c: In function 'x':
constant_not_constant.c:4:9: error: first argument to '__builtin_choose_expr' not a constant
  return __builtin_choose_expr(__builtin_constant_p(y), 1, 0);
         ^

$ i386-linux-gcc -v
Using built-in specs.
COLLECT_GCC=i386-linux-gcc
COLLECT_LTO_WRAPPER=/home/cody/x-buildall/libexec/gcc/i386-linux/4.8.1/lto-wrapper
Target: i386-linux
Configured with: /home/cody/g/gcc/configure --target=i386-linux --enable-targets=all --prefix=/home/cody/x-buildall --enable-languages=c --without-headers --enable-sjlj-exceptions --with-system-libunwind --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-decimal-float --disable-libquadmath --enable-checking=release --disable-libatomic : (reconfigured) /home/cody/g/gcc/configure --target=i386-linux --enable-targets=all --prefix=/home/cody/x-buildall --enable-languages=c --without-headers --enable-sjlj-exceptions --with-system-libunwind --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-decimal-float --disable-libquadmath --enable-checking=release --disable-libatomic : (reconfigured) /home/cody/g/gcc/configure --target=i386-linux --enable-targets=all --prefix=/home/cody/x-buildall --enable-languages=c --without-headers --enable-sjlj-exceptions --with-system-libunwind --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-decimal-float --disable-libquadmath --enable-checking=release --disable-libatomic : (reconfigured) /home/cody/g/gcc/configure --target=i386-linux --enable-targets=all --prefix=/home/cody/x-buildall --enable-languages=c --without-headers --enable-sjlj-exceptions --with-system-libunwind --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-decimal-float --disable-libquadmath --enable-checking=release --disable-libatomic
Thread model: single
gcc version 4.8.1 20130328 (prerelease) (GCC)
Comment 1 Cody P Schafer 2013-03-28 00:56:11 UTC
This also affects my ubuntu gcc install:

$ gcc constant_not_constant.c  -O3 -c
constant_not_constant.c: In function ‘x’:
constant_not_constant.c:4:31: error: first argument to ‘__builtin_choose_expr’ not a constant

$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
Comment 2 Marek Polacek 2013-03-28 06:55:55 UTC
I guess dup of PR19449.
Comment 3 Marek Polacek 2013-03-28 06:57:56 UTC
.

*** This bug has been marked as a duplicate of bug 19449 ***