C++ Logo

std-proposals

Advanced search

Re: [std-proposals] noexcept has gotten a bit hairy -- I want a compiler error

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Mon, 28 Apr 2025 10:13:12 +0100
On Mon, 28 Apr 2025, 07:00 Julian Waters, <tanksherman27_at_[hidden]> wrote:

> Hi Jonathan,
>
> I can't address every point, but the point I was making is that I
> *don't* want to have to use noexcept everywhere, but as it stands now
> you *have* to do that if you so much as have 1 function you want to be
> noexcept (Such as operator new for instance) but don't want the
> handlers in the final binary for certain reasons.


What reasons? Why are the "dreaded handlers" such a problem? If you're
using exceptions, then you need them. If you're not, compile with
-fno-exceptions of -fno-enforce-eh-specs, possibly just for a single
function by putting that function in its own translation unit compiled with
-fno-enforce-eh-specs. That way callers still see it's noexcept, but the
implementation of the function assumes that nothing it calls will ever
throw, so it doesn't add the EH frame that terminates. That would be
suitable for an operator new implementation that calls a malloc that isn't
marked noexcept.

Received on 2025-04-28 09:13:28