Date: Sun, 29 Jun 2025 13:08:24 +0100
On Sun, 29 Jun 2025, 12:54 Tymi, <tymi.cpp_at_[hidden]> wrote:
> I understand you are referring to P2831; if that's the case, maybe we
> could involve contracts here? Seems like they are the best solution to our
> problem?
>
I'm not convinced there's a problem at all.
But if you added a contact assertion there, you would have to consider that
the contract violation handler could throw.
> Tymi.
>
> On Sun, 29 Jun 2025, 13:49 Tymi, <tymi.cpp_at_[hidden]> wrote:
>
>> It sure has preconditions, but so does start_lifetime_as,
>> start_lifetime_as_array, to_pointer etc etc, and they ARE specified as
>> noexcept
>>
>> 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...
>>>>
>>>>
>>>>
> I understand you are referring to P2831; if that's the case, maybe we
> could involve contracts here? Seems like they are the best solution to our
> problem?
>
I'm not convinced there's a problem at all.
But if you added a contact assertion there, you would have to consider that
the contract violation handler could throw.
> Tymi.
>
> On Sun, 29 Jun 2025, 13:49 Tymi, <tymi.cpp_at_[hidden]> wrote:
>
>> It sure has preconditions, but so does start_lifetime_as,
>> start_lifetime_as_array, to_pointer etc etc, and they ARE specified as
>> noexcept
>>
>> 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:08:43