[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [?] egcs increases C++ binary size dramatically



On Tue, Apr 07, 1998 at 11:14:17PM +0000, Falk Hueffner wrote:
> It seems that programs are larger even if they do not use exceptions
> at all (possibly even C programs). For those, it seems totally
> resonable to disable exceptions. It should probably even added to the
> policy, since it saves space.

Well, the rule is that every possible exception will be thrown that could be
thrown in the function ("assume the worst"). You have to declare the thrown
exceptions explicitely if you want to restrict the list (which does make
sense, doesn't it?).

C programs should be compiled with a C compiler.

Exception handling is broken enough yet. Please don't make it even more
unsafe by disabling it in some parts of the programming environment.

Note that by ANSI C++ even the new operator may throw an exception ( bad_alloc()
), and this operator is used in nearly every C++ program. For compatibility
with C functions, you can disable this with new(nothrow).

Hoever, I thought about what I said: I don't think that the program will be
smaller when the exceptions are declared, but some compile-time checking can
be done.

Note that the saving of space is misleading: Notably, a C++ program that
uses exceptions for error handling instead convential methods can even be
smaller, and the source code is *much* cleaner and shorter. It is not
uncommon to have half of the code provided for error handling. With
exceptions, this shrinks down significant. So, the bigger size is more a
sign of unefficient C++ programming style. Only to use exceptions in a few
places and use other global error handling strategies most of the time is
IMHO unnecessary.

Marcus
who prefers safety over brevity.


-- 
"Rhubarb is no Egyptian god."        Debian GNU/Linux        finger brinkmd@ 
Marcus Brinkmann                   http://www.debian.org    master.debian.org
Marcus.Brinkmann@ruhr-uni-bochum.de                        for public  PGP Key
http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/       PGP Key ID 36E7CD09


--
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: