From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EB72D3858D39; Wed, 10 Apr 2024 09:15:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB72D3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712740547; bh=AMc9G+nBgwoTvYAutDALwhAqOMlVrK5utjh0K1zl2ag=; h=From:To:Subject:Date:From; b=pPQuySKESOEmCMqWJyCHSZlgzCkPaBY4JlvvjhhpHD4p6WGIUz8gHWQsJMM8LQKZ+ TOtHtcq0UpIm2ORrXYygvReAI//g2YjwpDqtqHNsxU8v5uugpHF+0oV4giHtj1PQcM Kx6drkjjHvPmx9j9tLv6TVoBm5flNFf5BeO5dQgo= From: "Simon.Richter at hogyros dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114675] New: warning for "reference to not fully constructed object" Date: Wed, 10 Apr 2024 09:15:47 +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.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Simon.Richter at hogyros dot de 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=3D114675 Bug ID: 114675 Summary: warning for "reference to not fully constructed object" Product: gcc Version: 13.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Simon.Richter at hogyros dot de Target Milestone: --- We have an object that contains several sub-objects that should reference e= ach other through interface pointers. I'd like to make sure that interface poin= ters given to objects constructed later already point to initialized objects. So, for struct everything { everything() : a(), b(c), c(a) { } A a; B b; C c; }; I'm passing a reference to the not-yet-constructed C object to B's construc= tor, so this is unsafe despite being legal C++. I wonder if it would be possible= to generate a warning here.=