dereferencing a null pointer in a constant expression #75716
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
question
A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
undefined behaviour
Should it be possible to dereference a null pointer in a C++20 constant expression?
Consider this c++20 code:
I would expect this to not compile due to the dereferencing of a null pointer in a constant expression.
With reference to https://godbolt.org/z/q53rz5d69
clang-17.0.1 produces errors and warning, by default.
By default, gcc-13.2 compiles without warning. -Wall yields a -Wnonnull warning.
msvc 19.38 compiles without warning.
Potentially relevant context:
Accessing static data members via null pointer
Implicit undefined behavior when dereferencing pointers
I have submitted the same question for gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113047
The text was updated successfully, but these errors were encountered: