https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110619
Bug ID: 110619
Summary: Dangling pointer returned from constexpr function
converts in nullptr
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
The following function
constexpr auto f() {
int i = 0;
return &i;
};
returns dangling pointer on stack variable, but it is not nullptr. So next
assertion passes in Clang and MSVC:
static_assert( f() != nullptr );
But in GCC the assertion fails. Online demo:
https://gcc.godbolt.org/z/6E4rE963n