C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Defect report: not possible to declare-but-not-define a full specialization of a variable template

From: Thiago Macieira <thiago_at_[hidden]>
Date: Tue, 14 Jan 2025 06:13:18 -0800
On Tuesday 14 January 2025 03:29:32 Pacific Standard Time Avi Kivity wrote:
> Errors:
>
> <source>:14:13: error: explicit specialization of 'x' after
> instantiation
> 14 | int A<int>::x = 4;
>
> | ^
>
> <source>:6:24: note: explicit instantiation first required here
> 6 | extern template struct A<int>;
>
> | ^
>
> 1 error generated.
> Compiler returned: 1

Works with three other compiler front-ends:
https://gcc.godbolt.org/z/ddTqrqn7f

I don't know if this is a Clang bug or just under-specified in the standard.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2025-01-14 14:13:25