[Bug c++/113047] dereferencing a null pointer in a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113047 Marek Polacek changed: What|Removed |Added Last reconfirmed||2024-01-18 CC||mpolacek at gcc dot gnu.org Status|UNCONFIRMED |NEW Ever confirmed|0 |1
[Bug c++/113047] dereferencing a null pointer in a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113047 Nathaniel Shead changed: What|Removed |Added CC||nathanieloshead at gmail dot com --- Comment #4 from Nathaniel Shead --- I've pushed a fix for PR102420 (and hence comment #1), but looking at the DR this isn't sufficient for the result of CWG2823, for which presumably all of the following should also start erroring as well (note none of these error in Clang yet either): struct X { static constexpr int f() { return 0; } }; constexpr int g(X* x) { return (*x).f(); } // error constexpr int a = g(nullptr); constexpr int h(X* x) { return x->f(); } // error constexpr int b = h(nullptr); // and similarly constexpr int test() { int* p = nullptr; *p; // error return 0; } constexpr int t = test();
[Bug c++/113047] dereferencing a null pointer in a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113047 Jiang An changed: What|Removed |Added CC||de34 at live dot cn --- Comment #3 from Jiang An --- CWG2823 has been voted into the standard (see https://wg21.link/p3046r0, https://wg21.link/n4972). > Should it be possible to dereference a null pointer in a C++20 constant > expression? Now such derefencing is clearly UB and needs to cause constant evaluation failure (not only in C++20, IMO).
[Bug c++/113047] dereferencing a null pointer in a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113047 Andrew Pinski changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=102420 --- Comment #2 from Andrew Pinski --- I suspect this is a dup of bug 102420 .
[Bug c++/113047] dereferencing a null pointer in a constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113047 --- Comment #1 from gcc_bz at brnz dot org --- I have submitted this same question for clang: https://github.com/llvm/llvm-project/issues/75716