C++ Logo

std-discussion

Advanced search

Re: pointer to volatile, but no volatile object

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 05 Jun 2023 15:41:45 -0700
On Monday, 5 June 2023 12:42:12 PDT Federico Kircheis via Std-Discussion
wrote:
> For what is worth, even a static_cast seems to hinder optimizations
>
> void foo(){
> int a = -1;
> *static_cast<volatile int*>(&a) = 42;
> }

The compilers probably think that "if you are trying to waste CPU cycles here,
you must have a reason".

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-06-05 22:41:48