https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109367
Nathaniel Shead <nshead at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nshead at gcc dot gnu.org --- Comment #5 from Nathaniel Shead <nshead at gcc dot gnu.org> --- I think the warning is correct (i.e. this is not a bug). The namespace-scope declaration of the lambda is not keyed to any decl and so will be distinct in each TU. Consider the example given here: https://eel.is/c++draft/basic.def.odr#18 More formally, a lambda type has no linkage in general. But for a definable item D with definitions in multiple TUs, any entities declared within D (including lambda closure types) are treated as if only one was declared. But a type alias is not a definable item (https://eel.is/c++draft/basic.def.odr#1) and so that doesn't apply in this case, so we just follow the normal linkage rules and so there can be no possible matching corresponding declaration of `S::f(T)` in this example since the type referred to by T has no linkage and thus will not correspond to any declaration in other TUs. The original code could be "fixed" by instead doing: struct T_impl { using type = decltype([]{}); }; using T = T_impl::type; or perhaps even struct T : decltype([]{}) {}; since this would attach the lambda to be within a definable item that can be declared across different TUs.