[Jason]
> 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?
After issuing a diagnostic, sure.
-- Gaby
From: Core <core-bounces@lists.isocpp.org> On Behalf Of
Hubert Tong via Core
Sent: Tuesday, September 21, 2021 8:48 AM
To: core@lists.isocpp.org
Cc: Hubert Tong <hubert.reinterpretcast@gmail.com>; sg12@lists.isocpp.org
Subject: Re: [isocpp-core] Implementation defining undefined behavior
On Tue, Sep 21, 2021 at 11:44 AM Herring, Davis via Core <core@lists.isocpp.org> wrote:
> 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?
For this case in particular, SG6 (or at least Lawrence) has in the past recommended against supporting it <https://wiki.edg.com/bin/view/Wg21issaquah2016/CoreWorkingGroup#Core_issue_2168_Narrowing_conver> <https://lists.isocpp.org/sci/2016/03/0000.php>.
More generally, I don't think it's conforming to "define undefined behavior" during constant evaluation, even though it obviously is so at runtime. Of course, you can always issue a diagnostic and accept the program anyway.
And enjoy much fun with SFINAE (and with extensions like VLAs).
Davis
_______________________________________________
Core mailing list
Core@lists.isocpp.org
Subscription:
https://lists.isocpp.org/mailman/listinfo.cgi/core
Link to this post:
http://lists.isocpp.org/core/2021/09/11539.php