[Bug c++/113047] dereferencing a null pointer in a constant expression

nathanieloshead at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Dec 19 22:31:59 GMT 2023


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113047

Nathaniel Shead <nathanieloshead at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathanieloshead at gmail dot com

--- Comment #4 from Nathaniel Shead <nathanieloshead at gmail dot com> ---
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();


More information about the Gcc-bugs mailing list