public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64077] New: dynamic_cast incorrectly rejected for private base
@ 2014-11-25 22:58 gcc at dixie dot net.nz
  2014-11-26 20:31 ` [Bug c++/64077] " daniel.kruegler at googlemail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gcc at dixie dot net.nz @ 2014-11-25 22:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64077

            Bug ID: 64077
           Summary: dynamic_cast incorrectly rejected for private base
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at dixie dot net.nz

I believe this is rejects-valid:

class Base { public: virtual ~Base () {} };
class Derived: virtual Base { public: virtual ~Derived() {} };
class D2: virtual public Base, public Derived { public: D2() {} ~D2() {} };

#include <cassert>
int main ()
{
        Derived *p = new D2;
        assert(dynamic_cast<Base *>(p)); // unexpected error: ‘Base’ is an
inaccessible base of ‘Derived’
}


The following lookup_base call should not issue errors.  Also it should do
access checks at global scope, not using friendship or access rights granted by
the local scope.

--- orig/gcc/cp/rtti.c     2014-06-13 08:47:08.000000000 +1200
+++ new/gcc/cp/rtti.c       2014-11-25 19:13:06.656252034 +1300
@@ -626,8 +626,8 @@ build_dynamic_cast_1 (tree type, tree ex
      convert statically.  */
   {
     tree binfo = lookup_base (TREE_TYPE (exprtype), TREE_TYPE (type),
-                             ba_check, NULL, complain);
-    if (binfo)
+                             ba_check | ba_ignore_scope, NULL, 0);
+    if (binfo && binfo != error_mark_node)
       return build_static_cast (type, expr, complain);
   }
>From gcc-bugs-return-468583-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Nov 25 23:04:16 2014
Return-Path: <gcc-bugs-return-468583-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 4442 invoked by alias); 25 Nov 2014 23:04:16 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 4374 invoked by uid 48); 25 Nov 2014 23:04:02 -0000
From: "d.g.gorbachev at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/59332] Segmentation fault in inline_summary with LTO + attribute optimize
Date: Tue, 25 Nov 2014 23:04: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: 4.9.0
X-Bugzilla-Keywords: accepts-invalid, ice-on-invalid-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: d.g.gorbachev at gmail dot com
X-Bugzilla-Status: NEW
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:
Message-ID: <bug-59332-4-Sf5P7ytZct@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59332-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59332-4@http.gcc.gnu.org/bugzilla/>
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: 2014-11/txt/msg03055.txt.bz2
Content-length: 245

https://gcc.gnu.org/bugzilla/show_bug.cgi?idY332

--- Comment #7 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> ---
Recent GCC 5 accepts both "lto" and "no-lto". However, they work on a per-file
rather then on a per-function basis...


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-27 21:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-25 22:58 [Bug c++/64077] New: dynamic_cast incorrectly rejected for private base gcc at dixie dot net.nz
2014-11-26 20:31 ` [Bug c++/64077] " daniel.kruegler at googlemail dot com
2014-11-27  7:59 ` gcc at dixie dot net.nz
2014-11-27 20:15 ` gcc at dixie dot net.nz
2014-11-27 21:05 ` daniel.kruegler at googlemail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).