[Bug middle-end/69482] Writing through pointers to volatile not always preserved

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jan 9 11:46:15 GMT 2023


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69482

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note we do expand volatile qualified variables to memory but this case is about
non-volatile qualified variables stored to through volatile qualified pointers.
So it's

int foo (int i)
{
  volatile int j = i;
  return j;
}

vs.

int bar (int i)
{
  int j;
  *(volatile int *)&j = i;
  return j;
}

I have a patch.


More information about the Gcc-bugs mailing list