Is dynamic_cast' ing a NULL pointer safe

Discussion in 'C++' started by Rahul, Mar 17, 2010.

  1. Rahul

    Rahul Guest

    Hi All,

    Is the following statement safe when ptr1 value is NULL

    Derived *ptr2 = dynamic_cast<Derived *>(ptr1)

    though it works properly in VC++ yet I wanted to know if it is
    considered safe as per the c++ standard (like delete NULL;)

    Thanks in advance
    Rahul
    Rahul, Mar 17, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Songling

    safe to delete null pointer?

    Songling, Dec 3, 2004, in forum: C++
    Replies:
    3
    Views:
    27,875
    Stuart Gerchick
    Dec 3, 2004
  2. Ganesh
    Replies:
    3
    Views:
    483
    red floyd
    May 23, 2005
  3. aneuryzma
    Replies:
    3
    Views:
    693
    Jim Langston
    Jun 16, 2008
  4. Christopher
    Replies:
    4
    Views:
    431
    Ruben Safir
    Jul 9, 2011
  5. Michael Granger
    Replies:
    0
    Views:
    435
    Michael Granger
    Jun 10, 2011
Loading...

Share This Page