C++ Logo

std-proposals

Advanced search

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

From: Filip <fph2137_at_[hidden]>
Date: Sun, 27 Apr 2025 13:10:11 +0200
I love the idea, but some time ago I thought about making it mandatory, if compiled with exceptions, to have noexcept(false) or noexcept marked for every function.
Enforced by checks to throw outside catch statements.

On the other hand I wonder if throw is essentially a fancy special return we could reimplement it as std::excepted or something…
Just a loose thought.

Cheers, Filip

> Wiadomość napisana przez Jan Schultke via Std-Proposals <std-proposals_at_[hidden]> w dniu 27 kwi 2025, o godz. 06:55:
>
> 
> The issue with the proposal is that many functions exist that don't throw but aren't marked noexcept, or which only throw under circumstances that you don't trigger. For example, the callee can throw on failed bounds checks, but the caller makes sure that indices are within bounds. Personally, I only use noexcept when a function has a wide contract, i.e. it succeeds no matter what, with no preconditions/assertions. noexcept(explicit) would be pretty much useless to me.
>
> Also note that the usefulness of noexcept is dramatically overstated by some developers. You should probably pay attention to it on special member functions, swap(), and a few other key functions, but it has virtually no impact anywhere else.
>
> > I fed my idea in ChatGPT and asked it to produce one concise paragraph
> > describing the benefits this new feature could bring, and it gave me
> > back:
>
> I'm not going to read that AI slop. Is this some out-of-season April Fool's joke?
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-04-27 11:10:28