From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128326 invoked by alias); 12 Oct 2015 18:20:08 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 128289 invoked by uid 48); 12 Oct 2015 18:20:04 -0000 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/67942] diagnose placement new buffer overflow Date: Mon, 12 Oct 2015 18:20:00 -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: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to 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-SW-Source: 2015-10/txt/msg00919.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D67942 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot g= nu.org --- Comment #1 from Martin Sebor --- A patch capable of detecting and diagnosing a limited subset of such overfl= ows will be posted for review shortly. The output of the patch for the example program in the Description is as follows: $ g++ -Wall u.cpp u.cpp: In function =E2=80=98void f(S*)=E2=80=99: u.cpp:22:27: warning: placement new constructing a 16-byte object of type = =E2=80=98S=E2=80=99 in a region of type =E2=80=98char [8]=E2=80=99 that is 8 bytes large S *t =3D new (buf) S (*s); >>From gcc-bugs-return-499365-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Oct 12 18:35:17 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 61739 invoked by alias); 12 Oct 2015 18:35:17 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 61720 invoked by uid 48); 12 Oct 2015 18:35:13 -0000 From: "barry.revzin at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/67943] New: Friend declaration applied to base class, leading to allowing access to protected base Date: Mon, 12 Oct 2015 18:35:00 -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: 5.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: barry.revzin 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: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-10/txt/msg00920.txt.bz2 Content-length: 884 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67943 Bug ID: 67943 Summary: Friend declaration applied to base class, leading to allowing access to protected base Product: gcc Version: 5.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- gcc 5.2 compiles the following: struct Base { }; struct Derived : protected Base { }; struct Derived2 : public Derived { friend void test(); }; void test() { Derived a; Base* p = &a; } int main(){ test(); } If you comment out the friend declaration in Derived2, which should be irrelevant to the example, then gcc reports an error that Base is an inaccessible base of Derived.