Harald van Dijk <
true...@gmail.com> wrote:
> On May 22, 11:14 am, Jun Woong <
wo...@icu.ac.kr> wrote:
>
> > Given this code:
>
> > extern void p1;
> > extern const void p2;
>
> > p1;
> > p2;
> > (void)p1;
> > (void)p2;
>
> > is a conforming implementation required to issue diagnositcs?
> [...]
> > Note here that /void/ written in italics excludes qualified types;
> > see DR012 for C90.
>
> The answer for DR012 says
>
> extern const void p2;
> &p2;
>
> is valid. In &p2;, p2 is a primary expression, so DR012 answers your
> question for the lines involving p2.
Not quite. Qualified void is excluded from /void/ in the text of the
standard, so there is no problem in p2's being a primary expression.
Of course, being a primary expression does not make unadorned use of
p2 in expressions valid since we have:
6.3.2.1p2
Except when it is the operand of [sizeof, &, ++, -- ...], an lvalue
that does not have array type is converted to the value stored in
the designated object [...] If the lvalue has incomplete type and
does not have array type, the behavior is undefined.
What about p1? It designates an object (with unenough information
that cannot be satisfied forever), but because it is of unqualified
void type, it is uncertain for that identifier to be a primary
expression.
>
> A reasonable argument can be made that both p1 and p2 are declared as
> designating objects, despite not having object type, and that the
> parenthesised text in 6.5.1p2 ("in which case it is an lvalue") is
> incorrect.
Agreed.