https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94470
Bug ID: 94470
Summary: Constexpr variable initialization with self-modifying
constructor incorrectly rejected since r7-6728
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ppalka at gcc dot gnu.org
Target Milestone: ---
$ cat testcase.C
struct X
{
int b = 0;
int c = ((this->b=1), 1);
};
constexpr X o = { };
static_assert(o.b == 1);
$ g++ -std=c++17 testcase.C
testcase.C:7:19: error: modification of ‘o’ is not a constant expression
constexpr X o = { };
^
testcase.C:9:19: error: non-constant condition for static assertion
static_assert(o.b == 1);
~~~~^~~~