🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Martin E. Nordberg III Fri, 22 Mar 1996 02:20
dynamic_cast<const B&>
#3772
Author: Martin E. Nordberg III
Date: Fri, 22 Mar 1996 02:20
30 lines
1756 bytes
    I just installed MS VC++ 4.1.  The following code (strained 
from my larger code) now fails to compile:

    class A { virtual ~A() };
    class B : public A {};

    void test( const A&  a )
      {
        const B& b = dynamic_cast<const B&>( a );
          // gives "... error ... cannot use dynamic_cast to 
          // convert from 'const A &' to 'const B &' "
      }

    Did Microsoft goof or did I?  The draft standard (Sect. 5.2.6) 
seems to equate a reference to an lvalue for dynamic_cast, but 
gives no clear wording for this case.  The same problem happens 
for const A* to const B*.
    If the new MSVC++ behavior is correct, why?
(Eagerly awaiting BC++ 5.0, hope it really works with MFC)

-- 
Martin E. Nordberg III
Quintessoft Engineering, Inc.
"Visualizing new patterns of software development."
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Re: dynamic_cast<const B&>
#3790
Author: Nathan Myers, http://www.cantrip...
Date: Sun, 24 Mar 1996 04:43
28 lines
1669 bytes
Martin E. Nordberg III wrote:
> 
>   I just installed MS VC++ 4.1.  The following code (strained
> from my larger code) now fails to compile:
> 
>     class A { virtual ~A() };
>     class B : public A {};
> 
>     void test( const A&  a )
>       { const B& b = dynamic_cast<const B&>( a ); }
> 
>   Did Microsoft goof ... ?

"Heh heh heh."

But seriously... new implementations from the Draft are bound to 
have mistakes.  What's important is whether they get fixed after
attention is called to them.  I'll be interested to see whether
the next release still has this bug.

Nathan Myers
ncm@cantrip.org  http://www.cantrip.org/
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads