[Bug c++/67582] typeof(*p) * fails when p is void *
vegard.nossum at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Sep 15 14:05:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67582
--- Comment #5 from Vegard Nossum <vegard.nossum at gmail dot com> ---
(In reply to Jonathan Wakely from comment #4)
> But *p is not a valid expression, so you might as well ask for
> typeof(this is nonsense and not valid C++).
>
> You also can't ask for sizeof(*p) for a void pointer.
The following bits from the standard draft seem to support what you say:
[basic.compound].3 "The type of a pointer to void or a pointer to an object
type is called an object pointer type. [ Note: A pointer to void does not have
a pointer-to-object type, however, because void is not an object type. — end
note ]"
[expr.unary.op].1 "The unary * operator performs indirection: the expression to
which it is applied shall be a pointer to an object type, or a pointer to a
function type and the result is an lvalue referring to the object or function
to which the expression points."
More information about the Gcc-bugs
mailing list