Date: Tue, 09 Dec 2025 09:00:32 -0800
On Tuesday, 9 December 2025 03:39:52 Pacific Standard Time David Brown via Std-
Proposals wrote:
> A test implementation (considering only small, simple types) of
> "hide_value" for gcc and clang could be :
>
> T hide_value(T x)
> {
> __asm__ volatile ("" : "+g" "" (x));
> }
Just FYI, I've needed this before, in other contexts. Admittedly, our code is
very niche and this is often tied to assembly in one way or another. But it's
not just cryptography that would use it.
In our case, our objective is to make the same computation multiple times,
over and over again, and verify that it's the same every time. Unfortunately,
sometimes the compiler realises it *is* the same computation and eliminates
the "multiple times" part of it, resulting in a loop over memcmp()...
Proposals wrote:
> A test implementation (considering only small, simple types) of
> "hide_value" for gcc and clang could be :
>
> T hide_value(T x)
> {
> __asm__ volatile ("" : "+g" "" (x));
> }
Just FYI, I've needed this before, in other contexts. Admittedly, our code is
very niche and this is often tied to assembly in one way or another. But it's
not just cryptography that would use it.
In our case, our objective is to make the same computation multiple times,
over and over again, and verify that it's the same every time. Unfortunately,
sometimes the compiler realises it *is* the same computation and eliminates
the "multiple times" part of it, resulting in a loop over memcmp()...
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Received on 2025-12-09 17:00:42
