From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 46CBB3858C52; Wed, 28 Jun 2023 17:15:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 46CBB3858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687972552; bh=XK/pUG2vIRHbihFPgrx0hIelp5xkLrV4t43xL7HzPIk=; h=From:To:Subject:Date:From; b=gnav+8Hwbk6Ms5Jmug5N1V5GtgMU/7UUIQnm0Efyu5yy6wXITbAkUGYjIi/jK9+MA Hnayat4wa38QKZbBKcUVnvSlohaLWlbyj9TlLYmzLKhJtaZO1psi6wdZhsRGKUebzz ysAI+fJ9HIWctbigR1Ds1l+nf1AbzWD9/kcb+GMg= From: "fchelnokov at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110463] New: Mutable subobject is usable in a constant expression Date: Wed, 28 Jun 2023 17:15:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fchelnokov at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110463 Bug ID: 110463 Summary: Mutable subobject is usable in a constant expression Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fchelnokov at gmail dot com Target Milestone: --- The following program is invalid per https://timsong-cpp.github.io/cppwp/n4861/expr.const#4.8 (An object or reference is usable in constant expressions if it is ... a non-mutable subobject) struct U { mutable int x =3D 2; }; int main() { constexpr U u{}; u.x =3D 1; static_assert( u.x =3D=3D 2 ); // must fail, but ok in GCC } but GCC accepts it. Online demo: https://gcc.godbolt.org/z/n8MYzhbad=