C++ Logo

sg12

Advanced search

Re: [SG12] [isocpp-core] Implementation defining undefined behavior

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Tue, 21 Sep 2021 15:54:43 +0000
[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_at_[hidden]> On Behalf Of Hubert Tong via Core
Sent: Tuesday, September 21, 2021 8:48 AM
To: core_at_[hidden]
Cc: Hubert Tong <hubert.reinterpretcast_at_[hidden]>; sg12_at_[hidden]
Subject: Re: [isocpp-core] Implementation defining undefined behavior

On Tue, Sep 21, 2021 at 11:44 AM Herring, Davis via Core <core_at_[hidden]<mailto:core_at_[hidden]>> 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://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.edg.com%2Fbin%2Fview%2FWg21issaquah2016%2FCoreWorkingGroup%23Core_issue_2168_Narrowing_conver&data=04%7C01%7Cgdr%40microsoft.com%7Ce72111c1454c46f188ff08d97d1758ad%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637678361531296227%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3TtkozpEkGjRRtMna2E0e%2FiFAkI4PW7LDEseRFO0O6w%3D&reserved=0>> <https://lists.isocpp.org/sci/2016/03/0000.php<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.isocpp.org%2Fsci%2F2016%2F03%2F0000.php&data=04%7C01%7Cgdr%40microsoft.com%7Ce72111c1454c46f188ff08d97d1758ad%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637678361531306221%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=sdgFMUGv90gLXIvBrOBqgxsxZITbDzXK2x8%2FEfaCNmY%3D&reserved=0>>.

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_at_[hidden]<mailto:Core_at_[hidden]>
Subscription: https://lists.isocpp.org/mailman/listinfo.cgi/core<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fcore&data=04%7C01%7Cgdr%40microsoft.com%7Ce72111c1454c46f188ff08d97d1758ad%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637678361531316214%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=dUo82PO3ninP8hwX9%2Fpd%2FqIE9cJ35BE0kwX1DedA5ag%3D&reserved=0>
Link to this post: http://lists.isocpp.org/core/2021/09/11539.php<https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.isocpp.org%2Fcore%2F2021%2F09%2F11539.php&data=04%7C01%7Cgdr%40microsoft.com%7Ce72111c1454c46f188ff08d97d1758ad%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637678361531316214%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jEj7cDJCVGP4PwTg%2BVseLM0mh58Fib070akbPtGq%2BFs%3D&reserved=0>

Received on 2021-09-21 10:54:47