On Jun 4, 2012, at 13:42 , Richard Smith <[email protected]> wrote:
>>> union S {
>>> // ... no use of Aligner ...
>>> private:
>>> void *Aligner;
>>> unsigned char Data[8];
>>> };
>>>
>>> Perhaps we should conservatively disable the diagnostic for union members?
>>
>>
>> Why should we not warn in this case? I think in general we might want to
>> exempt char-arrays as they are commonly use for alignment, but other than
>> that?
>
> Aligner is 'unused', but has a semantic effect. Note that in the
> clang::DependentFunctionTempateSpecializationInfo case, there is no
> char array. I'm concerned that a warning for cases like this would
> have a high false positive rate. (I have the same concern for padding
> members in structs, but I would expect those to generally be public,
> since such structs are usually intended to be PODs.)
It'd be nice if we could silence this warning by making Aligner nameless, but
as I read the standard that's not allowed.
[class.mem]p1: Except when used to declare friends (11.3) or to introduce the
name of a member of a base class into a derived class (7.3.3),
member-declarations declare members of the class, and each such
member-declaration shall declare at least one member name of the class.
And indeed we warn on such a case (poorly):
> class X {
> void *;
> };
> <stdin>:2:8: error: expected member name or ';' after declaration specifiers
> void *;
> ~~~~ ^
(the arrow is pointing to the semicolon, and only 'void' is underlined)
As such I would go with Richard and say union members should be allowed to be
unused. Class members can be used for alignment too, but that's a lot rarer and
users can always turn the warning off.
Jordan
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits