Details
Details
- Reviewers
aaron.ballman erichkeane tahonermann shafik
Diff Detail
Diff Detail
Event Timeline
Comment Actions
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, "");
}