From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5F53B393A434; Thu, 8 Apr 2021 00:20:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F53B393A434 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/18635] [DR 504] use of uninitialised reference accepted (without -Wuninitialized) in C++ front end Date: Thu, 08 Apr 2021 00:20:41 +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: 3.4.3 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: SUSPENDED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2021 00:20:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D18635 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org --- Comment #18 from Martin Sebor --- What is this a request for? GCC 11 issues the warnings below, as well as for most of the test cases her= e.=20 Since (I assume most of us agree) rejecting the code would not be correct/conforming, is there something else to enhance? (There are bugs/limitations in -Wuninitialized that prevent diagnosing some similar ca= ses but I'd expect to track those as bugs separately from this request.) $ cat t.C && gcc -S -Wall t.C const int* fcp (const int *); void gcp () { const int *p =3D fcp (p); // -Wuninitialized } const int& fcr (const int &); void gcr () { const int &i =3D fcr (i); // -Wuninitialized } int& fr (int &); void gr () { int &r =3D fr (r); // -Wuninitialized } t.C: In function =E2=80=98void gcp()=E2=80=99: t.C:5:22: warning: =E2=80=98p=E2=80=99 is used uninitialized [-Wuninitializ= ed] 5 | const int *p =3D fcp (p); // -Wuninitialized | ~~~~^~~ t.C:5:14: note: =E2=80=98p=E2=80=99 was declared here 5 | const int *p =3D fcp (p); // -Wuninitialized | ^ t.C: In function =E2=80=98void gcr()=E2=80=99: t.C:12:22: warning: =E2=80=98i=E2=80=99 is used uninitialized [-Wuninitiali= zed] 12 | const int &i =3D fcr (i); // -Wuninitialized | ~~~~^~~ t.C:12:14: note: =E2=80=98i=E2=80=99 was declared here 12 | const int &i =3D fcr (i); // -Wuninitialized | ^ t.C: In function =E2=80=98void gr()=E2=80=99: t.C:19:15: warning: =E2=80=98r=E2=80=99 is used uninitialized [-Wuninitiali= zed] 19 | int &r =3D fr (r); // -Wuninitialized | ~~~^~~ t.C:19:8: note: =E2=80=98r=E2=80=99 was declared here 19 | int &r =3D fr (r); // -Wuninitialized | ^=