https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102881
--- Comment #1 from 康桓瑋 <hewillk at gmail dot com> --- (In reply to 康桓瑋 from comment #0) > template<int N> > using R = decltype([] { return 0; }()); > > template <int N> > auto you_can_see_me() -> R<N> { > return {}; > } > > int main() { > you_can_see_me<0>(); > } > > GCC rejects with: > > <source>:10:3: error: 'you_can_see_me' was not declared in this scope > 10 | you_can_see_me<0>(); > | ^~~~~~~~~~~~~~~~~ > > https://godbolt.org/z/7WEsjjscT Even broken when there is no trailing return type: #include <concepts> template<class> struct O {}; template<std::size_t> using R = decltype([] { return O<int>{}; }()); template <int N> constexpr R<N> get_variant() { return {}; } static_assert(std::same_as<R<0>, O<int>>); auto x = get_variant<0>(); static_assert(!std::same_as<decltype(x), O<int>>); static_assert(std::same_as<decltype(x), int>); https://godbolt.org/z/4bKccTEe5