C++ Logo

std-proposals

Advanced search

Re: [std-proposals] consteval hashing of compile-time constant compound literals

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 16 May 2024 17:35:50 -0700
On Thursday 16 May 2024 15:08:48 GMT-7 Frederick Virchanza Gotham via Std-
Proposals wrote:
> so then we'll be able to use std::bit_cast on a std::tuple to pass it
> into a consteval hash function.

That's not an acceptable use-case. The layout of std::tuple is an
implementation detail and may have padding bits, so you shouldn't bit_cast it.
And you should definitely not do that in a constexpr/consteval scenario.

Hashing padding bits is also not an acceptable use-case.


-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Fleet Engineering and Quality

Received on 2024-05-17 00:35:55