=== on 28 Mar 2015, 22:27:24 Evgeny Mandrikov wrote:
\[~freddy.mallet] [~ann.campbell.2] Words "evaluate a 'void' type" doesn't sound good/correct for me, might be better to change on "operand of a void type".

=== on 30 Mar 2015, 13:11:23 Ann Campbell wrote:
\[~evgeny.mandrikov] how about 'should not be used on "void"' ?

=== on 30 Mar 2015, 13:19:51 Evgeny Mandrikov wrote:
\[~ann.campbell.2] fine. But in any case I don't see how second example connected with description, which relates to RSPEC-2215.

=== on 31 Mar 2015, 13:14:15 Evgeny Mandrikov wrote:
\[~ann.campbell.2] I suspect that [~freddy.mallet] misunderstood Cppcheck rule, so that correct example looks like:

{noformat}

void test() {

  void* p;

  sizeof(*p);

}

{noformat}

and in this case there is indeed no intersection with RSPEC-2215.

=== on 31 Mar 2015, 14:30:56 Ann Campbell wrote:
updated

=== on 31 Mar 2015, 14:37:20 Evgeny Mandrikov wrote:
\[~ann.campbell.2] Title wasn't changed, so I did change and now spec LGTM.

=== on 31 Mar 2015, 16:07:26 Ann Campbell wrote:
\[~evgeny.mandrikov] title was changed as I thought you'd agreed. But okay.

=== on 31 Mar 2015, 16:24:04 Evgeny Mandrikov wrote:
\[~ann.campbell.2] I wasn't agree with word "evaluate", which remained in "used to evaluate 'void'", but I was agree with "used on 'void'" :) and finally took a decision to go ahead with my own proposal :)

=== on 9 Apr 2015, 08:25:07 Evgeny Mandrikov wrote:
\[~ann.campbell.2] In fact I didn't found that C standard forbids this, whereas {cpp} standard indeed forbids. Also GCC warns about this in {cpp} mode and still compiles, and doesn't warn in C mode. This *GNU extension* is indeed most probably originated from GCC compiler, but exists in some others for compatibility reasons - for example behavior of ICC (Intel Compiler) is the same as GCC, whereas Clang rejects this in {cpp} mode, but accepts in C without any warnings. Also statement "gcc is not a conforming C compiler by default" sounds a bit strong and aggressive. Based on this I think that we should adjust description.

=== on 9 Apr 2015, 09:15:10 Evgeny Mandrikov wrote:
\[~ann.campbell.2] however most probably I'm wrong about C standard, so taking ticket back to provide more details.

=== on 9 Apr 2015, 13:22:26 Evgeny Mandrikov wrote:
C11 6.5.3.4p1:

____
The sizeof operator shall not be applied to an expression that has function type or an incomplete type, to the parenthesized name of such a type, or to an expression that designates a bit-field member. The _Alignof operator shall not be applied to a function type or an incomplete type.

____
and C11 6.2.5p19:

____
The void type comprises an empty set of values; it is an incomplete object type that cannot be completed.

____
from where I conclude that indeed usage of "void" is not allowed by C11 standard.

And indeed - GCC 4.8.4 and Clang 3.6.0 would warn about this in "pedantic" C mode, but not ICC 15.0.2.


CPP11 5.3.3p1:

____
The sizeof operator shall not be applied to an expression that has function or incomplete type, ...

____
CPP11 5.3.6p1:

____
An alignof expression yields the alignment requirement of its operand type. The operand shall be a type-id representing a complete object type or an array thereof or a reference to a complete object type.

____
CPP11 3.9.1p9:

____
The void type is an incomplete type that cannot be completed.

____
So that not allowed by CPP11 too.

As was stated before - Clang will reject with error, GCC and ICC will show warning.


I hope this is enough to clarify description.

Also scope can be extended to cover "alignof" for which compilers behave in the same way as for "sizeof".

=== on 13 Apr 2015, 20:25:02 Evgeny Mandrikov wrote:
LGTM.

