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: unassignedclangb...@nondot.org Reporter: e...@80386.nl CC: llvm-bugs@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.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs