[Bug c/96810] This is a case that gcc shoud not compile successfully, but gcc acts opposite.

weiwt.fnst at cn dot fujitsu.com gcc-bugzilla@gcc.gnu.org
Mon Aug 31 08:28:44 GMT 2020


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

--- Comment #4 from Wei Wentao <weiwt.fnst at cn dot fujitsu.com> ---
>>--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
>>Actually sorry, the diagnostics clang emits is not about the bug mentioned in
>>the testcase, but about something different.
>>And while the bug described in the comment is really hard to diagnose at
>>compile time and in most cases impossible, what clang diagnoses is the fact
>>that
>>the target construct has implicit map(tofrom:A) clause and because the target
>>data maps only a small part of it, it mapping in target construct will fail.
>>Still, clang implements it incorrectly, it e.g. rejects:
>>int A[30];

>>void
>>foo (void)
>>{
>>  #pragma omp target data map (A[0:4])
>>  #pragma omp target
>>  A[2] = 0;
>>}

>>int
>>main ()
>>{
>>  #pragma omp target data map (A)
>>  foo ();
>>  return 0;
>>}

>>or

>>void bar (int *, int);

>>void
>>foo (void)
>>{
>>  int A[30];
>>  bar (A, 0);
>>  #pragma omp target data map (A[0:4])
>>  #pragma omp target
>>  A[2] = 0;
>>  bar (A, 1);
>>}

>>Both are completely valid and e.g. the latter could work just fine at runtime
>>if bar performs #pragma omp target enter data (arg1[:30]) for arg2 0 and exit
>>data for arg2 non-zero.
>>Perhaps a warning might be ok, but it still can have many false positives
>>(unless the compiler can prove that the array can't be mapped before the outer
>>target data).


More information about the Gcc-bugs mailing list