This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/16147] New: dynamic_cast fails to enforce accesssibility


Consider the following program

#include <assert.h>

struct A { virtual ~A() { } };

struct B : A { };

A* f() {
   struct C : private B {

      A* g() { return this; }
   };

   return (new C)->g();
}

int main()
{
   assert(dynamic_cast<B*>(f()) == 0);
}


According to 5.2.7/8, I believe the assert should pass.
I'm seeing this behaviour on GCC-3.3.x and probably before that too.

-- 
           Summary: dynamic_cast fails to enforce accesssibility
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gdr at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: plateform independent


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16147


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]