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

--- Comment #23 from Nana Sakisaka <aroma.slope.seven at gmail dot com> ---
Here are some additional test cases that implementers might find interesting:

// g++ -std=c++23 -fno-delete-null-pointer-checks (also implied by
-fsanitize=undefined)

inline constexpr int x = 1;
inline constexpr int y = 2;
static_assert(&x != &y); // error

template<class T> inline constexpr int vt = 0;
static_assert(&vt<int> != &vt<long>); // error
static_assert(&vt<int> != nullptr); // error
static_assert(&vt<int> == &vt<int>); // OK: the same object

template<class T> static constexpr int st = 0;
static_assert(&st<int> != &st<long>); // error: internal linkage does not help

namespace { template<class T> constexpr int ut = 0; }
static_assert(&ut<int> != &ut<long>); // error

constexpr int gx = 1;
constexpr int gy = 2;
static_assert(&gx != &gy); // OK: neither inline nor a template
  • [Bug sanitizer/71962] erro... aroma.slope.seven at gmail dot com via Gcc-bugs
    • [Bug sanitizer/71962]... aroma.slope.seven at gmail dot com via Gcc-bugs

Reply via email to