https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84592

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
So it's equivalent to:

$ cat ~/Programming/testcases/pr84592-3.c
#include <stdio.h>

int
main (void)
{
  int n[1];
  n[0] = 4;
#pragma omp target 
  {
    static const int test[] = {1,2,3,4};
    n[1] += test[n[0]];
  }

  printf ("n: %d\n", n[0]);

  return 0;
}

$ /tmp/install/usr/local/bin/x86_64-pc-linux-gnu-gcc
~/Programming/testcases/pr84592-3.c -fopenmp 
setting in_other_partition: test.2531: 1
test: 1
lto1: internal compiler error: in input_varpool_node, at lto-cgraph.c:1427
0x9840dc input_varpool_node
        /home/marxin/Programming/gcc2/gcc/lto-cgraph.c:1425
0x9840dc input_cgraph_1
        /home/marxin/Programming/gcc2/gcc/lto-cgraph.c:1547
0x9840dc input_symtab()
        /home/marxin/Programming/gcc2/gcc/lto-cgraph.c:1861
0x609f90 read_cgraph_and_symbols
        /home/marxin/Programming/gcc2/gcc/lto/lto.c:2891
0x609f90 lto_main()
        /home/marxin/Programming/gcc2/gcc/lto/lto.c:3356

It's logically not supported as I guess you have 2 versions of the pragma body
and thus 2 variables are expected. Proper fix would be to disable the pass in
case of an offloading is used.
And it's questionable whether an error should be printed for the test-case
above.

Reply via email to