[Bug tree-optimization/105864] New: storing nullptr_t to memory should not generate any instructions
vanyacpp at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jun 6 17:16:02 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105864
Bug ID: 105864
Summary: storing nullptr_t to memory should not generate any
instructions
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: vanyacpp at gmail dot com
Target Milestone: ---
Currently storing a nullptr_t to memory causes 0 to be written to that memory.
As there is no way to read this value back without invoking undefined behavior
I believe GCC can omit storing it.
This will make nullptr_t behave more similar to an empty struct that has only
padding bytes in it.
using nullptr_t = decltype(nullptr);
void test(nullptr_t* p)
{
*p = nullptr;
}
struct empty
{};
void test(empty* p)
{
*p = empty();
}
test(decltype(nullptr)*):
mov QWORD PTR [rdi], 0
ret
test(empty*):
ret
More information about the Gcc-bugs
mailing list