This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/69002] C front end should warn about undefined access to atomic structure or union


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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The footnote to 6.5.2.3/5 says "Members can be safely accessed using a
non-atomic object which is assigned to or from the atomic object."  Does it
mean that the following is OK?

typedef struct
{
  int x;
} S;

int
read1 (_Atomic S p)
{
  S s = p;
  return s.x;
}

int
read2 (_Atomic S *p)
{
  S *s = p;
  return s->x;
}

void
write1 (_Atomic S p, int x)
{
  S s = p;
  s.x = x;
}

void
write2 (_Atomic S *p, int x)
{
  S *s = p;
  s->x = x;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]