[Bug c++/97230] Invocation of non-static member function on a null instance in core constant expression should not be allowed
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97230 Marek Polacek changed: What|Removed |Added Keywords||patch --- Comment #3 from Marek Polacek --- https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555282.html
[Bug c++/97230] Invocation of non-static member function on a null instance in core constant expression should not be allowed
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97230 Marek Polacek changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org CC||mpolacek at gcc dot gnu.org Status|NEW |ASSIGNED
[Bug c++/97230] Invocation of non-static member function on a null instance in core constant expression should not be allowed
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97230 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2020-09-28 Ever confirmed|0 |1 Keywords|compile-time-hog|accepts-invalid --- Comment #2 from Jonathan Wakely --- GCC trunk does warn about exactly the issue: ce.cc: In function 'int main()': ce.cc:10:43: warning: 'this' pointer null [-Wnonnull] 10 | constexpr auto x = ((X*)nullptr)->foo(); | ^ ce.cc:4:19: note: in a call to non-static member function 'constexpr int X::foo() const' 4 | constexpr int foo(){ | ^~~ But that should be an error during constant evaluation.
[Bug c++/97230] Invocation of non-static member function on a null instance in core constant expression should not be allowed
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97230 --- Comment #1 from Eligor Kadaf --- Basically it described in 7th paragraph in [expr.const] of the latest C++ standard draft: https://eel.is/c++draft/expr.const#5