summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-upcast.c
blob: cb70838809a7e1b9f11679537dda858cfee2c848 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* { dg-do compile } */
/* { dg-options "-O2 -Wall" } */

struct a {
    int i;
};
struct b {
    struct a a;
    int j;
};
int main(void)
{
  static struct b b;
  struct a *ap=(struct a *)&b;
  return ((struct b *)&ap->i)->j; /* { dg-bogus "will break strict-aliasing" } */
}