On Thu, Sep 26, 2024 at 05:27:23PM -0400, Jason Merrill wrote: > On 9/26/24 1:29 AM, Nathaniel Shead wrote: > > On Tue, Sep 24, 2024 at 09:47:17AM +1000, Nathaniel Shead wrote: > > > Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? > > > > > > -- >8 -- > > > > > > [module.import] p6 says "A header unit shall not contain a definition of > > > a non-inline function or variable whose name has external linkage." > > > > > > This patch implements this requirement, and cleans up some issues in the > > > testsuite where this was already violated. To handle deduction guides > > > we mark them as inline, since although we give them a definition for > > > implementation by the standard they have no definition, and so should > > > not error in this case. > > > > > > One remaining question is the behaviour of code like: > > > > > > struct S { static const int x = 123; }; > > > > > > 'S::x' is not 'inline' here, but this is legal code as long as there is > > > exactly one definition elsewhere if 'x' is ever odr-used, as specified > > > by [class.static.data] p4. However, since it's not 'inline' then the > > > exemption for [module.import] does not apply, and so it appears uses of > > > this in header units should error. > > But that isn't a definition, only a declaration. So it's well-formed in a > header unit. > > https://eel.is/c++draft/class.static#data-3 > > Jason >
Ah right, thanks, completely missed that. I'll update this in the next version of this patch series I'll be sending out shortly. Nathaniel