Explicit Specialization in Non-Namespace Scope
The given code fails to compile in GCC despite compiling successfully in Clang. According to the C standard ([temp.expl.spec]), explicit specializations can be declared in any scope where the corresponding primary template could be defined.
This behavior appears to be a bug in GCC. According to CWG 727, the rule in [temp.expl.spec] regarding explicit specialization has been modified to allow such declarations in any relevant scope.
Scope of Explicit Specialization
The original standard stated that explicit specialization should be declared in a namespace enclosing the specialized template. However, the current standard permits explicit specialization in any scope where the primary template can be defined:
GCC's failure to adhere to this updated rule constitutes a bug. The issue has been identified as Bug 85282 and is currently tracked by the GCC development team.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3