https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119097
Nathaniel Shead <nshead at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Modules references internal |Modules treats non-ODR |linkage entity error |usages of constexpr values | |as exposure CC| |nshead at gcc dot gnu.org --- Comment #1 from Nathaniel Shead <nshead at gcc dot gnu.org> --- This is related to https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1815r2.html. Specifically, only exposures of TU-local entities should error; the bodies of inline functions will error, the bodies of non-inline should not. Functions defined in a class body are implicitly 'inline' (hence the errors when declared in the header file) unless attached to a named module (hence the errors not occurring when declared in the module). That said, for this specific instance none of these cases should error; by https://eel.is/c++draft/basic.link#14.4 we have: "A declaration is an exposure if it either names a TU-local entity (defined below), ignoring ... any reference to a non-volatile const object or reference with internal or no linkage initialized with a constant expression that is not an odr-use ([basic.def.odr])." None of these usages are ODR-uses, so this should be OK.