https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91264
Marek Polacek changed:
What|Removed |Added
Status|ASSIGNED|RESOLVED
Resolution|---
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91264
--- Comment #5 from Marek Polacek ---
Author: mpolacek
Date: Mon Aug 19 13:59:13 2019
New Revision: 274671
URL: https://gcc.gnu.org/viewcvs?rev=274671&root=gcc&view=rev
Log:
PR c++/91264 - detect modifying const objects in constexpr.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91264
Marek Polacek changed:
What|Removed |Added
Keywords||patch
--- Comment #4 from Marek Polacek
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91264
Marek Polacek changed:
What|Removed |Added
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed|
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91264
--- Comment #3 from Marek Polacek ---
Another:
struct X {
int j;
constexpr X() : j(0) { }
};
struct Y {
X x;
constexpr Y() : x{} { }
};
constexpr void
g ()
{
constexpr Y y{};
Y *p = const_cast(&y);
p->x.j = 99;
}
static_assert((
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91264
--- Comment #2 from Marek Polacek ---
Another test:
constexpr void
f (int &r)
{
r = 99;
}
constexpr int
f2 ()
{
const int i = 0;
f (const_cast(i));
return i;
}
constexpr int i = f2 ();
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91264
--- Comment #1 from Marek Polacek ---
Similar for e.g.
const_cast(i)++;