Comparing pointers to functions for constexpr fails with gcc not with clang
Tadeus Prastowo
tadeus.prastowo@unitn.it
Mon Jul 30 11:50:00 GMT 2018
Any opinion on the following matter I posted about two weeks ago?
On Thu, Jul 19, 2018 at 7:44 PM, Tadeus Prastowo
<tadeus.prastowo@unitn.it> wrote:
> Hi!
>
> Using http://godbolt.org, I see that the following program compiles in
> any clang version that supports -std=c++14 switch (>= 3.5) but fails
> in any GCC version >= 5.1 while compiles in any GCC version <= 4.9.4
> that supports -std=c++14 switch (>= 4.8.5):
>
> template<typename T, T v>
> struct carrier {
> static constexpr T value = v;
> };
>
> template<typename T>
> inline constexpr bool nontype_nontemplate_args_eq(T arg1, T arg2) {
> return arg1 == arg2;
> }
> template<typename T1, typename T2>
> inline constexpr bool nontype_nontemplate_args_eq(T1, T2) {
> return false;
> }
>
> int fn1() {
> return 2;
> }
>
> int fn2() {
> return 17;
> }
>
> int main() {
> return carrier<bool, nontype_nontemplate_args_eq(&fn1, &fn2)>::value;
> }
>
> Is this GCC bug?
>
> Thanks.
>
> --
> Best regards,
> Tadeus
More information about the Gcc-help
mailing list