lkml.org 
[lkml]   [2006]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Compiling C++ modules
Avi Kivity wrote:
>>
>>
>> The "advantages" of the former over the latter:
>>
>> (1) Without exceptions (which are fragile in a kernel), the former
>> can't return an error instead of initializing the Foo.
> Don't discount exceptions so fast. They're exactly what makes the code
> clearer and more robust.
>
> A very large proportion of error handling consists of:
> - detect the error
> - undo local changes (freeing memory and unlocking spinlocks)
> - propagate the error
>
> Exceptions make that fully automatic. The kernel uses a mix of gotos
> and alternate returns which bloat the code and are incredibly error
> prone. See the recent 2.6.16.x for examples.
C++ exceptions are much more error prone than C. Well not exactly error
prone, but more non-deterministic.
This is one of the reasons that Software standards allow C++ at lower
levels, e.g. DAL E, but at higher levels, e.g. DAL B, C++ is not
allowed, but C is.
So, one can conclude that a C program can be made more reliable than a
C++ program. One aim of a kernel is reliability.

James
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-04-25 12:26    [W:0.118 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site