[cfe-dev] Is it permitted to explicitly specialize a deleted function template?
Jeff Walden
jwalden+clang at mit.edu
Thu Mar 8 20:58:45 PST 2012
Is it an error to explicitly specialize a deleted function template? gcc and msvc seem to think it's fine, and both compile this example:
template<int i> int f() = delete;
template<> int f<4>() { return 4; }
int main() { return f<4>(); }
In contrast clang (r152210) sees an explicit specialization of a deleted function template as a redefinition:
> [jwalden at wheres-wally tmp]$ ~/Programs/clang-build/build/Release/bin/clang++ -std=c++11 clang-delete-bug.cpp
> clang-delete-bug.cpp:2:16: error: redefinition of 'f'
> template<> int f<4>() { return 4; }
> ^
> clang-delete-bug.cpp:2:16: note: previous definition is here
> clang-delete-bug.cpp:4:21: error: call to deleted function 'f'
> int main() { return f<4>(); }
> ^~~~
> clang-delete-bug.cpp:2:16: note: candidate function [with i = 4] has been explicitly deleted
> template<> int f<4>() { return 4; }
> ^
> 2 errors generated.
The N2346 default/delete proposal says that "One can define a template with a deleted definition. Specialization and argument deduction occur as they would with a regular template function, but explicit specialization is not permitted." and proposes editing 14.7.3 to allow an explicit specialization to declare only non-deleted function templates. But N3242 at least didn't make this change (I don't have the final spec), so I'm guessing this is a clang bug but don't know. Who's right?
Jeff
More information about the cfe-dev
mailing list