lkml.org 
[lkml]   [2024]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: RE: [PATCH 00/45] C++: Convert the kernel to C++
From
On 11. 01. 24, 20:40, David Laight wrote:
> I've seen the same issue with some C++ code that was like:
> (Pardon my C++ :-)
> foo = new();
> try {
> add_foo_to_list(foo);



> } except {
> free(foo);
> }
> The problem is that you have no idea whether the exception was
> thrown before or after 'foo' was saved.
> Since pretty much everything can 'throw' you really can't tell.

I don't follow, you can catch() specific (e.g. ENotAdded) exceptions.

> OTOH if add_foo_to_list() returns an error code you can know
> (and check) that zero is returned iff the pointer has been saved.

There is no difference between throwing exceptions (you can as well
embed an error code in a generic exception, if you want) and throwing
error numbers directly.

A different question is whether we want exceptions (RTTI) in the kernel
at all. Not sure about gcc, but for example LLVM does not.

regards,
--
js
suse labs


\
 
 \ /
  Last update: 2024-01-24 07:53    [W:0.456 / U:1.832 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site