qt, -fno-rtti i okolice
Marcin 'Qrczak' Kowalczyk
qrczak w knm.org.pl
Śro, 8 Gru 1999, 09:22:46 CET
Wed, 08 Dec 1999 00:26:34 +0100, Martin Dalecki <dalecki w cs.net.pl> pisze:
> > > > `-fno-rtti'
> > > > Disable generation of the information used by C++ runtime type
> > > > identification features (`dynamic_cast' and `typeid'). If you
> > > > don't use those parts of the language (or exception handling,
> > > > which uses `dynamic_cast' internally), you can save some space by
> > > > using this flag.
> > > Excpetions nie mają nic wspólnego z run time type informations.
> >
> > To dlaczego zacytowany fragment dokumentacji mówi co innego?
>
> Proszę oto tabliczka wartości dla junktora, zwanego alternatywą
> (do ktorego się chyba odnosisz):
Naprawdę uważasz, że mieli na myśli, że o ile nie używa się
dynamic_cast, to wyjątki działają? Ech...
Zresztą możesz sam sprawdzić. Wyjątki _nie_ działają przy -fno-rtti
(u mnie prosty przykład daje segmentation fault).
> Co nie zabronione jest doskonale dozwolone... W przeciwieństwie
> do np. Javy C++ nie wymaga wyłapywania wszystkich
> wyjątków. BTW. standard nawet nie definiuje co zwraca new, jeśli
> się niepowiedzie...
Nieprawda.
9 Storage for the object created by a new-expression is obtained from
the appropriate allocation function (_basic.stc.dynamic.allocation_).
When the allocation function is called, the first argument shall be
the amount of space requested (which shall be no less than the size of
the object being created and which may be greater than the size of the
object being created only if the object is an array).
[...]
18.4.1 Storage allocation and deallocation [lib.new.delete]
18.4.1.1 Single-object forms [lib.new.delete.single]
void* operator new(std::size_t size) throw(bad_alloc);
Effects:
The allocation function (_basic.stc.dynamic.allocation_) called by a
new-expression (_expr.new_) to allocate size bytes of storage suit-
ably aligned to represent any object of that size.
Replaceable:
a C++ program may define a function with this function signature
that displaces the default version defined by the C++ Standard
library.
Required behavior:
Return a pointer to dynamically allocated storage
(_basic.stc.dynamic_), or else throw a bad_alloc exception.
Jeśli się nie powiedzie, to new nic nie zwraca, tylko rzuca wyjątek.
Nie ma innej możliwości.
--
__("< Marcin Kowalczyk * qrczak w knm.org.pl http://qrczak.ids.net.pl/
\__/ GCS/M d- s+:-- a22 C+++>+++$ UL++>++++$ P+++ L++>++++$ E-
^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP->+ t
QRCZAK 5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-
Więcej informacji o liście dyskusyjnej pld-devel-pl