C++ Logo

sg12

Advanced search

[SG12] Implementation defining undefined behavior

From: Jason Merrill <jason_at_[hidden]>
Date: Tue, 21 Sep 2021 11:26:45 -0400
Historically, "undefined behavior" was sometimes used for patterns that
were supported on some platforms and not others. Many of those have since
become "conditionally supported", making the construct either well-formed
with defined behavior or ill-formed. But what about patterns that are
well-defined on some platforms and undefined on others?

I'm thinking specifically about floating point division by zero, which
sometimes hits a hardware exception and sometimes produces floating-point
infinity (when is_iec559 is true).

As with other cases of undefined behavior, this is made testable by
constexpr. Can an implementation say that a construct that is undefined in
the C++ standard is defined in that implementation, and therefore accept it
in constexpr?

Jason

Received on 2021-09-21 10:27:03