This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/69002] New: C front end should warn about undefined access to atomic structure or union
- From: "fw at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 21 Dec 2015 15:15:43 +0000
- Subject: [Bug c/69002] New: C front end should warn about undefined access to atomic structure or union
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69002
Bug ID: 69002
Summary: C front end should warn about undefined access to
atomic structure or union
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: fw at gcc dot gnu.org
Target Milestone: ---
The following code currently compiles without warnings (apart from the
-Wunused-but-set-parameter warning), but the standard says in 6.5.2.3/5 that
this results in undefined behavior.
typedef _Atomic struct
{
int x;
} S;
int
read1 (S p)
{
return p.x;
}
int
read2 (S *p)
{
return p->x;
}
void
write1 (S p, int x)
{
p.x = x;
}
void
write2 (S *p, int x)
{
p->x = x;
}
(Plus the same test for union instead of struct.)