On Fri, May 09, 2025 at 12:43:49PM +0200, David Hildenbrand wrote:
> > > Is this not pretty much equivalent to a volatile read where you're forcing
> > > the compiler to not optimise this unused thing away? In guard-regions I 
> > > set:
> > >
> > > #define FORCE_READ(x) (*(volatile typeof(x) *)x)
> > >
> > > For this purpose, which would make this:
> > >
> > > FORCE_READ(addr);
> > > FORCE_READ(&addr[pagesize]);
> >
> > Hmmm, a compiler might be allowed to optimize out a volatile read.
>
> Looking into this, the compiler should not be allowed to do that. So
> FORCE_READ() should work!

Yeah, was going to say I thought the compiler was explicitly forbidden from
doing this so is a rare case of 'volatile considered harmful' not being
quite so harmful :P

>
> --
> Cheers,
>
> David / dhildenb
>

Reply via email to