libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / 20200311-1.c
blobac82b6b7a0b0be70b2e337fbb227cd7f431a9a24
1 /* { dg-do run } */
3 struct list { struct list *n; };
5 struct obj {
6 int n;
7 struct list l;
8 } _o;
10 struct list _l = { .n = &_o.l };
12 int main(int argc, char *argv[])
14 struct obj *o = &_o;
15 _o.l.n = &_l;
16 while (&o->l != &_l)
17 /* Note the following is invoking undefined behavior but in
18 this kind of "obvious" cases we don't want to break things
19 unnecessarily and thus we avoid analyzing o as pointing
20 to nothing via the undefined pointer subtraction. Instead
21 we canonicalize the pointer subtraction followed by the
22 pointer conversion to pointer offsetting. */
23 o = ((struct obj *)((const char *)(o->l.n)
24 - (const char *)&((struct obj *)0)->l));
25 return 0;