[llvm-bugs] [Bug 26398] New: Regression: -Wnull-dereference (part of -Wall) even applies to expressions that are not evaluated.
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jan 30 15:04:21 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26398
Bug ID: 26398
Summary: Regression: -Wnull-dereference (part of -Wall) even
applies to expressions that are not evaluated.
Product: clang
Version: 3.8
Hardware: PC
OS: other
Status: NEW
Severity: release blocker
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: ed at 80386.nl
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
I just upgraded from LLVM+Clang 3.7.1 to LLVM+Clang 3.8.0rc1 and I noticed that
the following code now generates a compiler warning/error:
$ cat bla.c
#define some_generic_function(x) \
_Generic(*(x), \
int: some_generic_function_int)(x)
static int *some_generic_function_int(int *x) {
return x;
}
void some_function(void);
void some_function(void) {
some_generic_function((int *)0);
}
$ x86_64-unknown-cloudabi-cc -O3 -Wall -Werror bla.c
bla.c:11:3: error: indirection of non-volatile null pointer will be deleted,
not trap [-Werror,-Wnull-dereference]
some_generic_function((int *)0);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bla.c:2:14: note: expanded from macro 'some_generic_function'
_Generic(*(x), \
^~~~
bla.c:11:3: note: consider using __builtin_trap() or qualifying pointer with
'volatile'
bla.c:2:14: note: expanded from macro 'some_generic_function'
_Generic(*(x), \
^
1 error generated.
The warning should obviously not trigger in this case; the expression passed to
_Generic() is not evaluated. This is also not an uncommon construct. With
_Generic() you often want to match a type without any cv-qualifiers on the
pointer type. Dereferencing the expression is an easy way to get rid of those.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160130/abe20692/attachment.html>
More information about the llvm-bugs
mailing list