Date: Sun, 29 Jun 2025 13:06:10 +0100
On Sun, 29 Jun 2025, 12:50 Tymi, <tymi.cpp_at_[hidden]> wrote:
> It sure has preconditions, but so does start_lifetime_as,
> start_lifetime_as_array,
>
Those are low level "magic" functions that interact with the object model
and lifetimes.
to_pointer
>
Do you mean to_address? That has a wide contract, i.e. no preconditions.
etc etc, and they ARE specified as noexcept
>
There are a handful of low-level or performance critical functions where
the Lakos rule is intentionally not followed. But there are far, FAR more
examples of functions with narrow contracts that use 'Throws: Nothing'
instead of being noexcept.
You haven't provided enough justification for making an exception for
assume_aligned.
> Can't verify it because every single implementation marks it as noexcept
> anyway.
>
> Tymi.
>
> On Sun, 29 Jun 2025, 13:47 Jonathan Wakely, <cxx_at_[hidden]> wrote:
>
>>
>>
>> On Sun, 29 Jun 2025, 11:06 Tymi via Std-Proposals, <
>> std-proposals_at_[hidden]> wrote:
>>
>>> [ptr.align] specifies that `std::assume_aligned` throws *nothing*, so
>>> why isn't it already marked as `noexcept`?
>>>
>>
>> Because it has a precondition.
>>
>> Current signature:
>>> `template [[nodiscard]] constexpr T* assume_aligned(T* ptr);`
>>> Proposed signature:
>>> `template [[nodiscard]] constexpr T* assume_aligned(T* ptr) noexcept;`
>>>
>>> Impact on the standard: none
>>> Implementation: add noexcept specifier
>>>
>>> Reason: Better codegen on some compilers with exceptions (because of
>>> noexcept),
>>>
>>
>> Have you verified this?
>>
>>
>> after all this function is meant to be an optimisation point. Another
>>> smaller reason to use this function is noexcept functions, because some
>>> static analysers are not happy with using not noexcept functions in
>>> noexcept context...
>>>
>>>
>>>
> It sure has preconditions, but so does start_lifetime_as,
> start_lifetime_as_array,
>
Those are low level "magic" functions that interact with the object model
and lifetimes.
to_pointer
>
Do you mean to_address? That has a wide contract, i.e. no preconditions.
etc etc, and they ARE specified as noexcept
>
There are a handful of low-level or performance critical functions where
the Lakos rule is intentionally not followed. But there are far, FAR more
examples of functions with narrow contracts that use 'Throws: Nothing'
instead of being noexcept.
You haven't provided enough justification for making an exception for
assume_aligned.
> Can't verify it because every single implementation marks it as noexcept
> anyway.
>
> Tymi.
>
> On Sun, 29 Jun 2025, 13:47 Jonathan Wakely, <cxx_at_[hidden]> wrote:
>
>>
>>
>> On Sun, 29 Jun 2025, 11:06 Tymi via Std-Proposals, <
>> std-proposals_at_[hidden]> wrote:
>>
>>> [ptr.align] specifies that `std::assume_aligned` throws *nothing*, so
>>> why isn't it already marked as `noexcept`?
>>>
>>
>> Because it has a precondition.
>>
>> Current signature:
>>> `template [[nodiscard]] constexpr T* assume_aligned(T* ptr);`
>>> Proposed signature:
>>> `template [[nodiscard]] constexpr T* assume_aligned(T* ptr) noexcept;`
>>>
>>> Impact on the standard: none
>>> Implementation: add noexcept specifier
>>>
>>> Reason: Better codegen on some compilers with exceptions (because of
>>> noexcept),
>>>
>>
>> Have you verified this?
>>
>>
>> after all this function is meant to be an optimisation point. Another
>>> smaller reason to use this function is noexcept functions, because some
>>> static analysers are not happy with using not noexcept functions in
>>> noexcept context...
>>>
>>>
>>>
Received on 2025-06-29 12:06:28