C++ Logo

std-proposals

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 01 Jun 2025 23:39:06 -0300
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

Received on 2025-06-02 02:39:08