From: Paolo Carlini Date: Wed, 4 Oct 2017 20:58:52 +0000 (+0000) Subject: re PR c++/78131 (Inconsistent evaluation for `constexpr` lambdas in templates between... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=25139006e58a7ca7b708a742af8170f399d7db63;p=gcc.git re PR c++/78131 (Inconsistent evaluation for `constexpr` lambdas in templates between `static_assert`, `if constexpr(…)` and `constexpr` variables) 2017-10-04 Paolo Carlini PR c++/78131 * g++.dg/cpp1z/constexpr-lambda17.C: New. From-SVN: r253431 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6e8680b3312..b1e3edcb828 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-04 Paolo Carlini + + PR c++/78131 + * g++.dg/cpp1z/constexpr-lambda17.C: New. + 2017-10-04 Paolo Carlini PR c++/78018 diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda17.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda17.C new file mode 100644 index 00000000000..44bd2b83f94 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda17.C @@ -0,0 +1,30 @@ +// PR c++/78131 +// { dg-options -std=c++17 } + +template +constexpr auto f(TF) +{ + return [](auto...) constexpr { return true; }; +} + +// Compiles and works as intended. +template +void ok_0(T0) +{ + static_assert(f([](auto x) -> decltype(x){})(T0{})); +} + +// Compiles and works as intended. +template +void ok_1(T0) +{ + constexpr auto a = f([](auto x) -> decltype(x){})(T0{}); + if constexpr(a) { } +} + +// Compile-time error! +template +void fail_0(T0) +{ + if constexpr(f([](auto x) -> decltype(x){})(T0{})) { } +}