From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EEBE73857C45; Thu, 6 Aug 2020 23:46:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EEBE73857C45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1596757615; bh=e5c9Q71vQ4wY+S3fQHzMo5Bu3+ts5rob+obM18KLXXo=; h=From:To:Subject:Date:From; b=XxKz7KiawEjJoiLnm4SxXV6liQntkpGjEnf1gBWK/f2u0R0ussWDjJ33tQM8dSfaQ SQNo4mCp8mp2p1txWiE74iOuNhBKwjYvuqYPPGW78/bayrfv+rrh4FmNsaCpMk4d8T 6b/CfpiwgceextMBa7Uri+3SX3nyl6ru/SBM59DM= From: "mserdarsanli at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96511] New: Incorrect placement-new warning Date: Thu, 06 Aug 2020 23:46:55 +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: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mserdarsanli 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: 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 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, 06 Aug 2020 23:46:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96511 Bug ID: 96511 Summary: Incorrect placement-new warning Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mserdarsanli at gmail dot com Target Milestone: --- Below code causes the warning in the last line, which seems to be incorrect= . It affects all versions starting from GCC 8 Compiler explorer: https://godbolt.org/z/xhf6cr #include struct Foo { Foo() =3D default; Foo(int _a) : a(_a) {} int a =3D 0; }; void f() { Foo arr[2]; new (arr) Foo(10); // ok new (arr + 0) Foo(10); // ok new (&arr[0]) Foo(10); // ok new (&arr[1]) Foo(15); // ok new (arr + 1) Foo(15); // warning: placement new constructing an object= of type 'Foo' and size '4' in a region of type 'Foo [2]' and size '0' [-Wplacement-new=3D] }=