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

* [Bug c++/64077] dynamic_cast incorrectly rejected for private base
  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 ` daniel.kruegler at googlemail dot com
  2014-11-27  7:59 ` gcc at dixie dot net.nz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2014-11-26 20:31 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Andrew Dixie from comment #0)
> I believe this is rejects-valid:

I disagree with your interpretation. This was resolved a while ago by core
issue 665:

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#665

The essential wording that reflects this can be found in [expr.dynamic.cast]
p5:

"In both the pointer and reference cases, the program is ill-formed if cv2 has
greater cv-qualification than cv1 or if B is an inaccessible or ambiguous base
class of D."
>From gcc-bugs-return-468703-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Nov 26 20:52:21 2014
Return-Path: <gcc-bugs-return-468703-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 22351 invoked by alias); 26 Nov 2014 20:52:21 -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 22325 invoked by uid 48); 26 Nov 2014 20:52:17 -0000
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/64088] [5 Regression] ICE: in fold_abs_const, at fold-const.c:15550
Date: Wed, 26 Nov 2014 20:52:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mpolacek at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc target_milestone everconfirmed
Message-ID: <bug-64088-4-TJO26mg25B@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64088-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64088-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/msg03175.txt.bz2
Content-length: 613

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-11-26
                 CC|                            |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |5.0
     Ever confirmed|0                           |1

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.


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

* [Bug c++/64077] dynamic_cast incorrectly rejected for private base
  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
  3 siblings, 0 replies; 5+ messages in thread
From: gcc at dixie dot net.nz @ 2014-11-27  7:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Dixie <gcc at dixie dot net.nz> ---
(In reply to Daniel Krügler from comment #1)

Thanks for investigating and providing the reference.

I did not understand that upcasts were intended to override potential cross
casts, issue 665 makes this clear.

I agree the testcase is invalid.

In p5, is "inaccessible" meant to include friendship relationships granted by
the current scope or instead use the explicit public base rules spelt out in
p8?

The second part of the patch was implementing the latter, but I now also think
this is invalid.
>From gcc-bugs-return-468730-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Nov 27 08:35:27 2014
Return-Path: <gcc-bugs-return-468730-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6917 invoked by alias); 27 Nov 2014 08:35:26 -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 6877 invoked by uid 48); 27 Nov 2014 08:35:19 -0000
From: "manfred.rudigier at omicron dot at" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/62231] Exception handling broken on powerpc-e500v2-linux-gnuspe
Date: Thu, 27 Nov 2014 08:35:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.8.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: critical
X-Bugzilla-Who: manfred.rudigier at omicron dot at
X-Bugzilla-Status: UNCONFIRMED
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-62231-4-UeB2oDcZOY@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62231-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62231-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/msg03202.txt.bz2
Content-length: 260

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

--- Comment #2 from manfred.rudigier at omicron dot at ---
I've built 4.9.2 today and can also confirm that it is working with this
version, so it seems the bug has already been fixed in newer GCC versions.


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

* [Bug c++/64077] dynamic_cast incorrectly rejected for private base
  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
  3 siblings, 0 replies; 5+ messages in thread
From: gcc at dixie dot net.nz @ 2014-11-27 20:15 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Dixie <gcc at dixie dot net.nz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from Andrew Dixie <gcc at dixie dot net.nz> ---
(In reply to Daniel Krügler from comment #3)

Given the reference to core issue 665, I now think the wording and intent of
the standard is clear.

For completeness I've given an example below, but I'm happy this can be closed.

Thanks.


class base { virtual ~base() {} };
class derived : private base {
        friend bool t1(derived *);
};

bool t1(derived *x) {
        return dynamic_cast<base *>(x) != 0;
}

If the 'accessible' in p5 includes friendships relationships, then the
dynamic_cast should succeed.
If the 'accessible' in p5 requires a public base (like is required by p8), then
the dynamic cast should fail (or be ill-formed).
I think the wording of the standard clearly specifies succeed.
>From gcc-bugs-return-468795-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Nov 27 20:31:16 2014
Return-Path: <gcc-bugs-return-468795-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20352 invoked by alias); 27 Nov 2014 20:31: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 20327 invoked by uid 48); 27 Nov 2014 20:31:12 -0000
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/63833] REAL_PIC_OFFSET_TABLE_REGNUM is wrong for x86-64
Date: Thu, 27 Nov 2014 20:31:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: hjl.tools 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: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on target_milestone everconfirmed
Message-ID: <bug-63833-4-MvifIc9Unh@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63833-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63833-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/msg03267.txt.bz2
Content-length: 583

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-11-27
   Target Milestone|---                         |5.0
     Ever confirmed|0                           |1

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
The psABI

http://www.x86-64.org/svn/trunk/x86-64-ABI/

has been fixed.


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

* [Bug c++/64077] dynamic_cast incorrectly rejected for private base
  2014-11-25 22:58 [Bug c++/64077] New: dynamic_cast incorrectly rejected for private base gcc at dixie dot net.nz
                   ` (2 preceding siblings ...)
  2014-11-27 20:15 ` gcc at dixie dot net.nz
@ 2014-11-27 21:05 ` daniel.kruegler at googlemail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2014-11-27 21:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Andrew Dixie from comment #4)
> If the 'accessible' in p5 includes friendships relationships, then the
> dynamic_cast should succeed.

Yes, friendship relations need to be considered when accessibility is tested.

> If the 'accessible' in p5 requires a public base (like is required by p8),
> then the dynamic cast should fail (or be ill-formed).
> I think the wording of the standard clearly specifies succeed.

Yes.
>From gcc-bugs-return-468797-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Nov 27 21:05:04 2014
Return-Path: <gcc-bugs-return-468797-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 14765 invoked by alias); 27 Nov 2014 21:05:04 -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 14720 invoked by uid 48); 27 Nov 2014 21:05:00 -0000
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/63833] REAL_PIC_OFFSET_TABLE_REGNUM is wrong for x86-64
Date: Thu, 27 Nov 2014 21:05:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: hjl.tools at gmail dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-63833-4-4iZhxNV49t@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63833-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63833-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/msg03269.txt.bz2
Content-length: 414

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed.


^ 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).