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. Advertisements

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. Replies:
    5
    Views:
    30,331
    Mike Schilling
    Mar 29, 2006
  2. Ken
    Replies:
    69
    Views:
    13,387
    Michael D. Borghardt
    Jul 31, 2004
  3. Ken
    Replies:
    5
    Views:
    2,840
    Victor Bazarov
    Jul 24, 2004
  4. Songling

    safe to delete null pointer?

    Songling, Dec 3, 2004, in forum: C++
    Replies:
    3
    Views:
    28,427
    Stuart Gerchick
    Dec 3, 2004
  5. Felix Kater

    query pointer && *pointer: safe?

    Felix Kater, Dec 2, 2006, in forum: C Programming
    Replies:
    5
    Views:
    454
  6. aneuryzma
    Replies:
    3
    Views:
    978
    Jim Langston
    Jun 16, 2008
  7. Christopher
    Replies:
    4
    Views:
    651
    Ruben Safir
    Jul 9, 2011
  8. Michael Granger
    Replies:
    0
    Views:
    560
    Michael Granger
    Jun 10, 2011
Loading...