From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B99243858C62; Thu, 19 Jan 2023 16:51:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B99243858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674147064; bh=i7Jne8364AeQgBiVtQwLEyc4f8uL4EbudaU6VlxSToo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZuIAIIVZe5O8H5lnCJnO4hDun/f19uz+4fZNCseMoKthgKovRJ6q1LWwVAjKIpiRg AJHZUe3o/CT6slq5fYLDnvtMpzLa7Q5wX0Cbv23dJGR4p50ZT9FZfA9YZlxHTsJmPO qtHU7eDelqezJ3+h5ixFin+UJbL3x3y/La5QHJls= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53932] [10/11/12/13 Regression] C++ reference variable to member of anonymous union in global is error Date: Thu, 19 Jan 2023 16:51:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.3.4 X-Bugzilla-Keywords: ice-on-valid-code, link-failure, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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=3D53932 --- Comment #9 from Jakub Jelinek --- So, the problem is that build_anon_union_vars builds artificial variables f= or the anon union members and they those VAR_DECLs have DECL_VALUE_EXPR set to= the D.2763.i and similar COMPONENT_REFs. But VAR_DECLs with DECL_VALUE_EXPRs a= re only actually replaced with those DECL_VALUE_EXPR expressions during gimplification or regimplification (which explains why it works fine inside= of code in functions or global constructors). Nothing replaces them in DECL_INITIAL expressions of statically initialized vars.=