[cfe-dev] clang issue with 'mutable' ?

Steve McCoy mccoyst at gmail.com
Mon Oct 21 09:54:15 PDT 2013


Clang is right; gcc is wrong. [dcl.stc] of the standard says, "The mutable
specifier … cannot be applied to names declared const or static, and cannot
be applied to reference members."


On Mon, Oct 21, 2013 at 12:50 PM, Stefan Seefeld <stefan at seefeld.name>wrote:

> On 2013-10-21 12:35, David Blaikie wrote:
> > Interestingly GCC ToT (g++-tot (GCC) 4.9.0 20130829 (experimental))
> > rejects this the same way Clang does, but 4.8.1 does not (it accepts it).
>
> Interesting.  Unfortunately I still don't entirely understand why the
> code is rejected. Is there any wording in the C++ spec that suggests
> that the "wrapper" template may not be instantiated with some const type
> ? In my reading, a "mutable" member is simply a statement about it not
> being part of the "logically const" state of the containing object,
> which is entirely orthogonal to the question of whether the member
> itself is immutable. Obviously combining "const" and "mutable" in a
> single declaration is meaningless. But as in my code, both qualifiers
> can still end up in the same spot through parametrization, which seems
> entirely reasonable to me. Am I wrong ?
>
> While I can think of some workarounds, I'd rather understand what the
> issue is before making any attempt at working around it.
>
> Many thanks,
>         Stefan
>
> --
>
>       ...ich hab' noch einen Koffer in Berlin...
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131021/539b821c/attachment.html>


More information about the cfe-dev mailing list