[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ / multiple instances / iostreams
From: |
Hans Aberg |
Subject: |
Re: C++ / multiple instances / iostreams |
Date: |
Sat, 24 Jul 2004 14:41:43 +0200 |
At 11:40 +0200 2004/07/24, Detlef Vollmann wrote:
>> This may, by mistake, also happen, but then it shows up as a runtime error.
>> Because of this, it is probably better to use the dynamic_cast<T&> form, as
>> the code becomes simpler, and normally will not throw any exceptions. Any
>> eventual exceptions can be traced with a debugger with such capacity.
>In either case, you're in undefined behaviour territory here, as
>my_object_class is not a polymorphic type as required by 5.2.7p6.
>And undefined behaviour doesn't guarantee you a crash, but might
>produce silently wrong results...
As a matter of practise, one works with a single polymorphic hierarchy, and
all casts are on polymorphic objects. The mistakes I have, from time to
time, is when casting from one branch of the class tree to another, in
which case one gets a null pointer/exception.
But it is a good point. Perhaps there might be a need for the Bison %typed
option that used for a while.
Hans Aberg
- Re: C++ / multiple instances / iostreams, (continued)
- Re: C++ / multiple instances / iostreams, Detlef Vollmann, 2004/07/25
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/26
- Re: C++ / multiple instances / iostreams, Detlef Vollmann, 2004/07/26
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/27
- Re: C++ / multiple instances / iostreams, Detlef Vollmann, 2004/07/28
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/28
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/22
- Re: C++ / multiple instances / iostreams, Detlef Vollmann, 2004/07/23
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/23
- Re: C++ / multiple instances / iostreams, Detlef Vollmann, 2004/07/24
- Re: C++ / multiple instances / iostreams,
Hans Aberg <=
Re: C++ / multiple instances / iostreams, Oliver Kowalke, 2004/07/19
RE: C++ / multiple instances / iostreams, Urdaneta, Alfonso E (N-Summitt Technologies), 2004/07/22