https://wandbox.org/permlink/qSgjLEWzpsJmkHNU ---- template<class T> auto f = [](auto&& arg) -> T* { if constexpr (sizeof(arg) == 1) { return nullptr; } else { return static_cast<T*>(&arg); } }; auto p = f<int>(0); ---- prog.cc: In instantiation of 'auto f<int>': prog.cc:10:10: required from here prog.cc:2:6: warning: no return statement in function returning non-void [-Wreturn-type] auto f = [](auto&& arg) -> T* { ^ ---- This warning is bogus because both branches of `if constexpr` have a return statement. The warning will disappear when `if constexpr` is changed to `if`.
Started with r259043 PR c++/85149 - generic lambda and constexpr if. * pt.c (build_extra_args, add_extra_args): Split from tsubst_pack_expansion. (tsubst_expr) [IF_STMT]: Use them. * cp-tree.h (IF_STMT_EXTRA_ARGS): New.
Author: jason Date: Thu May 24 20:03:18 2018 New Revision: 260685 URL: https://gcc.gnu.org/viewcvs?rev=260685&root=gcc&view=rev Log: PR c++/85842 - -Wreturn-type, constexpr if and generic lambda. * pt.c (tsubst_lambda_expr): Copy current_function_returns_* to generic lambda. Added: trunk/gcc/testsuite/g++.dg/cpp1z/constexpr-if23.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c
Author: jason Date: Thu May 24 20:03:56 2018 New Revision: 260686 URL: https://gcc.gnu.org/viewcvs?rev=260686&root=gcc&view=rev Log: PR c++/85842 - -Wreturn-type, constexpr if and generic lambda. * pt.c (tsubst_lambda_expr): Copy current_function_returns_* to generic lambda. Added: branches/gcc-8-branch/gcc/testsuite/g++.dg/cpp1z/constexpr-if23.C Modified: branches/gcc-8-branch/gcc/cp/ChangeLog branches/gcc-8-branch/gcc/cp/pt.c
Fixed.
*** Bug 86495 has been marked as a duplicate of this bug. ***