shafik added a comment.

Two cases to consider: https://godbolt.org/z/ovofPExGK

  namespace MutableFields {
    class Foo {
    public:
      constexpr Foo() : I(1) {}
      mutable int I; // ref-note {{declared here}}
    };
  
  
    constexpr int foo() {
      constexpr Foo F;  
      F.I = 12;
      return F.I;
    }
    static_assert(foo() == 12, "");
  }

clang and gcc disagree on this one, I think clang is right not 100%.

and this one:

  namespace MutableFields {
    class Foo {
    public:
      constexpr Foo() : I(1) {}
      mutable int I; // ref-note {{declared here}}
    };
  
  
    constexpr int foo() {
      constexpr Foo F;  // A
      F.I = 12;
      constexpr int x = F.I; // B
      return F.I;
    }
    static_assert(foo() == 12, "");
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147621/new/

https://reviews.llvm.org/D147621

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to