Date: Fri, 25 Sep 2026 17:28:09 +0200
On 9/25/26 17:09, Frederick Virchanza Gotham via Std-Proposals wrote:
> "Where the ISO C++ Standard says that a particular thing results
> in undefined behaviour, is it okay for a particular compiler to say
> that the behaviour is well-defined and that the entire program must
> continue to function as normal?"
The Standard imposes no requirements on what happens in undefined
behavior, so it is valid for an implementation to do something
predictable, and it is valid for the implementation to document that
predictable behavior. If you then write a program that depends on that
predictable program, you are no longer writing in Standard C++ but in a
backwards-compatible dialect of C++. The behavior is well-defined in
that dialect, but not in Standard C++. Same as when using a compiler
extension.
> But now there's the sticky part: "Just because the throwing of an
> exception is an acceptable form of undefined behaviour, does this mean
> that the entire program must continue to function as normal?"
No. The Standard imposes no requirements on what happens in undefined
behavior. "The disk is erased, demon monkeys fly out of your nose, the
program turns into Tetris, and then an exception is thrown" is just as
valid as just throwing an exception.
> "Where the ISO C++ Standard says that a particular thing results
> in undefined behaviour, is it okay for a particular compiler to say
> that the behaviour is well-defined and that the entire program must
> continue to function as normal?"
The Standard imposes no requirements on what happens in undefined
behavior, so it is valid for an implementation to do something
predictable, and it is valid for the implementation to document that
predictable behavior. If you then write a program that depends on that
predictable program, you are no longer writing in Standard C++ but in a
backwards-compatible dialect of C++. The behavior is well-defined in
that dialect, but not in Standard C++. Same as when using a compiler
extension.
> But now there's the sticky part: "Just because the throwing of an
> exception is an acceptable form of undefined behaviour, does this mean
> that the entire program must continue to function as normal?"
No. The Standard imposes no requirements on what happens in undefined
behavior. "The disk is erased, demon monkeys fly out of your nose, the
program turns into Tetris, and then an exception is thrown" is just as
valid as just throwing an exception.
-- Rainer Deyke - rainerd_at_[hidden]
Received on 2026-09-25 15:28:19
