https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105236
Bug ID: 105236
Summary: failed lookup of alias with alias template of
dependent template parameter containing lambda in
unevaluated context
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: cooky.ykooc922 at gmail dot com
Target Milestone: ---
Code:
/// test_alias
template <typename F>
using test_alias = decltype([]{ return F{}; }());
/// test_temp
template <typename F>
struct test_temp {
using type = decltype([]{ return F{}; }());
};
struct Custom {};
/// test
template <typename F>
void test() {
// does not produce error in 'test_alias<Custom>'
using return_type = test_alias<F>;
return_type result;
// compiles fine with:
// 'test_alias<F> result;'
}
Expected Behavior:
this should compile with no compilation error same as other compilers such as
Clang, and MSVC
Compilation Error Message:
<source>: In function 'void test()':
<source>:L:C: error: 'return_type' was not declared in this scope
18 | return_type result;
Other workaround (with no compilation error):
template <typename F>
void test0() {
using return_type = test_temp<F>::type;
return_type result;
}
GCC Version: 12 (trunk)
Additional Command Line: -std=c++20
Compiler Explorer Link: https://godbolt.org/z/TKWxfKjnY