From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3F8AC38582B8; Mon, 17 Oct 2022 13:40:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F8AC38582B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666014023; bh=3db02vW8UQqnnbUzsplmPh1l3Kt/78Cu8bzD09Lo1/g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LGi7oEdWyPohju8Rt28UDNON3w1ZLm35XgvayhnNzcF+hjzEBbSPIgI8F8RwzxwSK sQ+2x/M1IbAfkWw5Zr1+ZHEN+N9PFV5GI3/E50VNHy0X8rzOsVDjwTiNIZe+kd5Tos R4CjJ7ocDWa1cJy98gXfW0+W3Np71Wj1mBbt/kiQ= From: "trass3r at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94184] Global variable inline constructor elision. Date: Mon, 17 Oct 2022 13:40:22 +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: 9.2.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: trass3r 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: cc 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=3D94184 Trass3r changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |trass3r at gmail dot com --- Comment #2 from Trass3r --- Even simpler example: const struct A { A() {} int a =3D 0; } a; The global ctor doesn't get eliminated while clang removes it: https://godbolt.org/z/9bjzMbx85 .section .text.startup,"ax",@progbits .type _GLOBAL__sub_I_example.cpp, @function _GLOBAL__sub_I_example.cpp: ret It works if you remove the member a.=