[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ / multiple instances / iostreams
From: |
Detlef Vollmann |
Subject: |
Re: C++ / multiple instances / iostreams |
Date: |
Sat, 24 Jul 2004 11:40:39 +0200 |
Hans Aberg wrote:
> At 11:04 +0200 2004/07/23, Detlef Vollmann wrote:
> >> class my_object_class {
> >> my_class data_;
> >> ...
> >> object_root* data() { return data_; }
> >> const object_root* data() const { return data_; }
> >> ...
> >> };
> >That was the part that was what was not clear to me.
> >As long as you don't dynamic_cast between different kinds of
> >my_object_class, your code is fine.
>
> 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...
Detlef
--
Detlef Vollmann vollmann engineering gmbh
Linux and C++ for Embedded Systems http://www.vollmann.ch/
- Re: C++ / multiple instances / iostreams, (continued)
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/25
- 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 <=
- Re: C++ / multiple instances / iostreams, Hans Aberg, 2004/07/24
Re: C++ / multiple instances / iostreams, Oliver Kowalke, 2004/07/19
RE: C++ / multiple instances / iostreams, Urdaneta, Alfonso E (N-Summitt Technologies), 2004/07/22