[llvm-bugs] [Bug 32115] constexpr variable template requires default initialization even though it's not instantiated
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 2 22:56:49 PST 2017
http://bugs.llvm.org/show_bug.cgi?id=32115
Richard Smith <richard-llvm at metafoo.co.uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
CC| |richard-llvm at metafoo.co.uk
Status|NEW |RESOLVED
--- Comment #2 from Richard Smith <richard-llvm at metafoo.co.uk> ---
[temp.res]p8: "The program is ill-formed, no diagnostic required, if [...] no
valid specialization can be generated for a template and the template is not
instantiated."
> that would be consistent with a constexpr function for example that
> can remain undefined unless it's actually used.
Clang rejects this case too, for the same reason:
template<typename T> constexpr void f() {
const int n;
}
> Eventually, I'm looking to specialize the tag for different type and
> letting the compile catch any untagged types.
This only triggers a warning (and a link error), but here's a valid way to get
something like what you want:
template<typename T> extern int kTag;
template<> constexpr int kTag<int> = 0;
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170303/273651ee/attachment.html>
More information about the llvm-bugs
mailing list