view libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-4.c @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 04ced10e8804
children
line wrap: on
line source

#include <stdlib.h>

#define N 32

unsigned int
foo (int n, unsigned int *a)
{
#pragma acc kernels copy (a[0:N])
  {
    a[0] = 2;

    for (int i = 0; i < n; i++)
      a[i] = 1;
  }

  return a[0];
}

int
main (void)
{
  unsigned int a[N];
  unsigned res, i;

  for (i = 0; i < N; ++i)
    a[i] = i % 4;

  res = foo (N, a);
  if (res != 1)
    abort ();

  return 0;
}