C++ Logo

std-proposals

Advanced search

[std-proposals] 回复: 回复: A Proposal about A New Keyword assure

From: SD SH <Z5515zwy_at_[hidden]>
Date: Mon, 2 Jun 2025 05:23:17 +0000
If sqrt is inlined function, they're same.
________________________________
发件人: Std-Proposals <std-proposals-bounces_at_[hidden]> 代表 Thiago Macieira via Std-Proposals <std-proposals_at_[hidden]>
发送时间: 2025年6月2日 10:39
收件人: std-proposals_at_lists.isocpp.org <std-proposals_at_[hidden]>
抄送: Thiago Macieira <thiago_at_[hidden]>
主题: Re: [std-proposals] 回复: A Proposal about A New Keyword assure

On Sunday, 1 June 2025 23:35:29 Brasilia Standard Time Thiago Macieira via
Std-Proposals wrote:
> On Sunday, 1 June 2025 13:28:34 Brasilia Standard Time Gašper Ažman via Std-
> Proposals wrote:
> > what does assure offer that contract_assert, pre, and post don't?
>
> And how about [[assume]]?
>
> [[assume(d > 0)]];
> d = sqrt(d);

https://gcc.godbolt.org/z/EYWWexzqv

You can see Clang and GCC already generate optimal code when the attribute is
present. The old-ICC case is a weird one because it defaults to "fast math"
mode despite the -fpmath:strict I inserted there; I don't recall what other
options I need. And, of course, MSVC does not generate optimal code, but that
is and has been the expected situation for a decade or more.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Platform & System Engineering



--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-06-02 05:23:27