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

            Bug ID: 79520
           Summary: Spurious caching for constexpr arguments
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: colu...@gmx-topmail.de
  Target Milestone: ---

constexpr int f(int const& x) {return x;}

constexpr struct S {
    int x = 0;
    constexpr S() {(void)f(x); x = 1;}
} s;

static_assert(f(s.x) == 1, "");

---

Presumably s.x is taken to be "immutable" because s is constexpr, while that's
obviously not true during the period of construction.

Reply via email to