view gcc/testsuite/gcc.dg/pr62030.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* { dg-do run } */
/* { dg-options "-O2" } */

extern void abort (void);

struct node
{
  struct node *next;
  struct node *prev;
};

struct node node;

struct head
{
  struct node *first;
};

struct head heads[5];

int k = 2;

struct head *head = &heads[2];

static int __attribute__((noinline))
foo (void)
{
  node.prev = (void *)head;
  head->first = &node;

  struct node *n = head->first;
  struct head *h = &heads[k];
  struct node *next = n->next;

  if (n->prev == (void *)h)
    h->first = next;
  else
    n->prev->next = next;

  n->next = h->first;
  return n->next == &node;
}

int
main (void)
{
  if (foo ())
    abort ();
  return 0;
}