Boost logo

Boost :

Subject: Re: [boost] [c++1] BOOST_NOEXCEPT macros?
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-10-31 07:15:32

Dave Abrahams wrote:
> on Fri Oct 28 2011, "Stewart, Robert" <Robert.Stewart-AT-
>> wrote:
> > Because the addition of the compiler-specific-nothrow
> > decoration implies lost optimization opportunities and the
> > addition of validation logic, it can affect client code in
> > undesirable ways.
> Rob, I don't know what you mean by "lost optimization
> opportunities and the addition of validation logic." The only
> compiler-specific behaviors I know of do the exact opposite:
> they add optimization opportunities and remove validation
> logic.

Code that is known not to throw exceptions can enable optimizations, but marking a function as non-throwing implies the need to call std::unexpected() which, in turn, implies the need for a function try block (or equivalent). That's the "validation logic" to which I referred.

That extra validation logic can reduce optimization opportunities, unless I'm much mistaken. For example, such a function cannot be inlined, or at least is much less likely to be inlined, because of the try block. (The function try block could be changed into a normal try block around the inlined function body.) Try blocks can reduce chances for optimization.

> Code can use the noexcept operator to detect noexcept-ness of
> expressions at compile-time and do something semantically
> different... but it shouldn't. Normally, noexcept should only
> be used for optimization.

Do note that we're discussing the effects on C++03 code in this context. The change is from no exception specification to throw() or its compiler-specific equivalent.

What have I misunderstood?

Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
Susquehanna International Group, LLP


IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

Boost list run by bdawes at, gregod at, cpdaniel at, john at