[cfe-commits] [Patch] Forbid C++11 attributes on explicit template instantiation.
richard at metafoo.co.uk
Wed Dec 12 18:28:18 PST 2012
On Wed, Dec 12, 2012 at 11:00 AM, John McCall <rjmccall at apple.com> wrote:
> On Dec 11, 2012, at 9:39 PM, Michael Han <fragmentshaders at gmail.com> wrote:
>> Thanks for the info. Do you happen to know why C++11 has this rule?
>> I got into this as I noted the same was implemented in gcc 4.8  while working on attributes. There are several options:
>> - Forbid C++11 attributes on explicit template instantiations and treat such program as ill formed.
>> - Issue a warning and ignore the attributes. This seems what gcc is doing.
>> - Issue a warning but not ignore the attributes. This allows existing visibility attributes migrate to new syntax with same semantics.
>> Which is the right direction to go here?
> My *guess* is that this rule exists to say that you can't modify semantic properties of an object in an explicit instantiation, and they aren't really considering semantic attributes where this makes sense, or semantic attributes which might reasonably modify the explicit instantiation itself. It'd be good to know more, though; maybe someone from the committee can chime in. Basically, I'm wondering whether this restriction might be lifted or modified in the future.
I don't know what the original rationale was, but since there can be
both explicit instantiations and implicit instantiations of the same
entity in the same program, the rule seems sensible to me (at least
for the cases where it's not possible to prevent the implementation
from performing implicit instantiations).
More information about the cfe-commits