From 25139006e58a7ca7b708a742af8170f399d7db63 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 4 Oct 2017 20:58:52 +0000 Subject: [PATCH] =?utf8?q?re=20PR=20c++/78131=20(Inconsistent=20evaluation?= =?utf8?q?=20for=20`constexpr`=20lambdas=20in=20templates=20between=20`sta?= =?utf8?q?tic=5Fassert`,=20`if=20constexpr(=E2=80=A6)`=20and=20`constexpr`?= =?utf8?q?=20variables)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2017-10-04 Paolo Carlini PR c++/78131 * g++.dg/cpp1z/constexpr-lambda17.C: New. From-SVN: r253431 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1z/constexpr-lambda17.C | 30 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1z/constexpr-lambda17.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6e8680b3312..b1e3edcb828 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2017-10-04 Paolo Carlini + PR c++/78131 + * g++.dg/cpp1z/constexpr-lambda17.C: New. + +2017-10-04 Paolo Carlini + PR c++/78018 * g++.dg/cpp1y/lambda-generic-78018.C: New. 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{})) { } +} -- 2.11.4.GIT