help-bison
[Top][All Lists]
Advanced

[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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]