| Date | Wed, 24 Jan 2024 07:53:13 +0100 | Subject | Re: RE: [PATCH 00/45] C++: Convert the kernel to C++ | From | Jiri Slaby <> |
| |
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
|