Subject: Re: [boost] [c++1] BOOST_NOEXCEPT macros?
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-10-28 11:20:27
Domagoj Saricj wrote:
> On 20.10.2011. 15:15, Stewart, Robert wrote:
> > Domagoj Saric wrote:
> >> On 19.10.2011. 17:47, Stewart, Robert wrote:
> >>> Using (1) on existing code could change behavior.
> >> Again, how could it change behaviour?
> >> Unless, again,: "...there is a real world person/problem
> >> that depends on the defined std::unexpected/std::terminate
> >> behaviour of noexcept as opposed to undefined or
> >> implementation defined behaviour of a compiler specific in
> >> case "someone violates a promise given about the particular
> >> function"..."
> > State it however you might like, but telling a compiler that
> > a function no longer emits any exceptions can mean changes
> > in optimization, insertion of validation logic, etc., which
> > can *change behavior*.
> AFAIK optimization is not allowed to manifest any change in
> behaviour, and the addition of noexcept already by itself
> changes/inserts "validation logic" so I still don't see what
> difference does that make?
Let me try it this way. With (1), we get the following before and after for C++03:
before: void f();
after: void f() compiler-specific-nothrow;
For C++11, (1) inserts noexcept, which was the reason for introducing it.
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.
The better option makes no change in C++03 code, which means no chance for undesirable changes.
It may well be useful to have a macro which inserts the compiler-specific-nothrow decoration for C++03 code and noexcept for C++11 code, but that's another macro. (You might argue the naming, if both are available, of course.)
Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
Susquehanna International Group, LLP http://www.sig.com
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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk