From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 03A7E386EC30; Wed, 29 Nov 2023 16:54:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03A7E386EC30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701276889; bh=l+i8cSiV9UjQ5qpcR8LF4E7LwlJNdPduDzP86bP7I6Q=; h=From:To:Subject:Date:From; b=jwW7TLEFWP7Q1ndps2AwgLCSuCoIrobWThK5Vv7oYI/XITYVWmORH8tWatHPwzkts /2xSr9d7GUxkjjBG9ajUoxQLY6YfY0uoe8VviDy2DQXRUGGtuFuuKjU2/iGJ8lX2Ic ylEoGXJw57c0XfD7oAJQO8LhPghAnvbhFH3mfSwU= From: "sss@li-snyder.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112766] New: [14 regression] spurious -Wmaybe-uninitialized with array new Date: Wed, 29 Nov 2023 16:54:48 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sss@li-snyder.org 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=3D112766 Bug ID: 112766 Summary: [14 regression] spurious -Wmaybe-uninitialized with array new Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sss@li-snyder.org Target Milestone: --- hi - With a recent checkout of gcc14 (20231129), on a x86_64-pc-linux-gnu host, the following source gives a bogus -Wmaybe-uninitialized warning with -Wall: -------------------------------------------------------------- void* operator new[](unsigned long, void* __p) ; class Result { public: Result(); ~Result(); }; void *foo(long nElements, void *p) { return p ? new((int*)p) Result[nElements] : new Result[nElements]; } -------------------------------------------------------------- $ g++ -c -O1 -Wall x.cc x.cc: In function =E2=80=98void* foo(long int, void*)=E2=80=99: x.cc:11:67: warning: =E2=80=98nElements.6=E2=80=99 may be used uninitialized [-Wmaybe-uninitialized] 11 | return p ? new((int*)p) Result[nElements] : new Result[nElements]; | ^ x.cc:11:58: note: =E2=80=98nElements.6=E2=80=99 was declared here 11 | return p ? new((int*)p) Result[nElements] : new Result[nElements]; | ^~~~~~~~~ We get the same warning with -O2 and -O3, but not -O0. This warning does not occur with gcc 13.2.1 20230728.=