https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106957
Bug ID: 106957 Summary: compiler error when calling lambda in decltype in trailing return type of function templated on T when passing T{} to the lambda Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: enricomaria.dean6elis at gmail dot com Target Milestone: --- Created attachment 53586 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53586&action=edit the output/error upon compilation Repro on godbolt (https://godbolt.org/z/9T5aEnzYa) Question on stackoverlow with a comment sayint that the code would be illegal anyway: https://stackoverflow.com/questions/73747517/sfinae-ing-on-a-nullary-lambda-expression-calling-a-non-templated-function-on-a Here's the code ``` #include <type_traits> constexpr auto f = [](int){}; template<typename T> auto canCallFOn(T) -> decltype([]{ f(T{}); }(), std::true_type{}); constexpr std::false_type canCallFOn(...) { return {}; } int main() { static_assert(!canCallFOn(1)); static_assert(!canCallFOn("")); } ```