Skip to content
Unverified Commit e07ead85 authored by Jun Zhang's avatar Jun Zhang
Browse files

[Clang] Warn when trying to dereference void pointers in C

Previously we only have an extension that warn void pointer deferencing
in C++, but for C we did nothing.

C2x 6.5.3.2p4 says The unary * operator denotes indirection. If it points
to an object, the result is an lvalue designating the object. However, there
is no way to form an lvalue designating an object of an incomplete type as
6.3.2.1p1 says "an lvalue is an expression (with an object type other than
void)", so the behavior is undefined.

Fixes https://github.com/llvm/llvm-project/issues/53631



Signed-off-by: default avatarJun Zhang <jun@junz.org>

Differential Revision: https://reviews.llvm.org/D134461
parent 5351878b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment