[Bug c++/115878] New: C++23: this int argument with value 0 considered as dereferencing a null pointer

fchelnokov at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jul 11 18:56:12 GMT 2024


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

            Bug ID: 115878
           Summary: C++23: this int argument with value 0 considered as
                    dereferencing a null pointer
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This C++23 program
```
struct w { constexpr int f(this int x) { return x; } };
static_assert((*&w::f)(1) == 1); //ok in Clang and GCC
static_assert((*&w::f)(0) == 0); //ok in Clang, error in GCC
```
is fully accepted by Clang, but GCC complains about the last line:
> error: dereferencing a null pointer
which is at least not-consistent with the accepted previous line.

Online demo: https://gcc.godbolt.org/z/6rWon4no4

Original discussion: https://stackoverflow.com/q/78733013/7325599


More information about the Gcc-bugs mailing list