[cfe-commits] [Patch] Forbid C++11 attributes on explicit template instantiation.
rjmccall at apple.com
Wed Dec 12 11:00:31 PST 2012
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.
The right solution is probably to accept these as an extension — maybe emitting a -pedantic warning — but to ignore/reject most attributes here. For example, we clearly don't want users to be able to specify an alignment on an explicit instantiation.
More information about the cfe-commits