[Bug c++/105864] storing nullptr_t to memory should not generate any instructions

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jun 21 02:30:52 GMT 2022


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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
A testcase where not doing the storing would might give wrong code:

using nullptr_t = decltype(nullptr);

[[gnu::noipa]]
void test(nullptr_t* p)
{
    *p = nullptr;
}

int main(void)
{
  nullptr_t t, t1 = nullptr;
  test(&t);
  char a[sizeof(t)], a1[sizeof(t)];
  __builtin_memcpy(&a[0], &t, sizeof(t));
  __builtin_memcpy(&a1[0], &t1, sizeof(t));
  if (__builtin_memcmp(&a[0], &a1[0], sizeof(a)) != 0)
    __builtin_abort();
  return 0;
}

So I suspect this should be marked as invalid.


More information about the Gcc-bugs mailing list