dwblaikie wrote:

> It looks like the presence of `static` on template variable specializations 
> makes difference in the namespace context: https://gcc.godbolt.org/z/WGsreqbz8
> 
> Specifically, the specializations not marked `static` result in an exported 
> variable. Thus, we have seemingly valid code that generates this diagnostic:
> 
> ```
> namespace A {
> template <unsigned N>
> static constexpr unsigned kMaxUnsignedInt = 2 * kMaxUnsignedInt<N - 1> + 1;
> 
> template <>
> static constexpr unsigned kMaxUnsignedInt<1> = 1;
> }
> ```
> 
> However, if we remove the `static` from the specialization, we're getting a 
> potential ODR violation (considering this code can be in a header included 
> into multiple translation units).
> 
> The right thing for this specific case is `inline constexpr`, but 
> nevertheless, there seems to be an inconsistency now in how Clang handles the 
> case now.

This seems to be pretty clearly a bug - in clang's specialization handling even 
prior to this patch.
GCC doesn't do this, it uses the storage class of the generic template for the 
specialization, which seems correct to me.

@sdkrystian are you interested in/able to fix this ^ ? 
https://gcc.godbolt.org/z/oPxKvvdeM


https://github.com/llvm/llvm-project/pull/93873
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to