Skip to content

[clang][bytecode] addressof is not constexpr #165952

@k-arrows

Description

@k-arrows

Reproducer:
https://godbolt.org/z/7j8YTGGM9

template <typename T> constexpr inline T *addressof(T &x) noexcept {
  return __builtin_addressof(x);
}

struct T {
  static T tt;
  constexpr T() : p(addressof(tt)) {}
  constexpr T *operator&() const { return p; }
  T *p;
};
constexpr T t;
T T::tt;
static_assert(&t == __builtin_addressof(T::tt), "");
static_assert(&t == addressof(T::tt), "");

When the above program is compiled with option -fexperimental-new-constant-interpreter enabled, it fails. When the option is disabled, it succeeds as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:bytecodeIssues for the clang bytecode constexpr interpreter

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions