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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Slightly better testcase:
void
foo (char **x)
{
  #pragma omp parallel for
  for (int i = 0; i < 16; i++)
    {
      char c[50];
      __builtin_strcpy (c, x[i]);
      void bar (void)
      {
        __builtin_strcat (c, "foo");
      }
    }
}

This ICEs all the way back to GCC 4.2/4.3.  And I'm not sure what can be done
about it.  Nested functions are implemented by adding all the variables that
can be accessed from nested functions into a single large frame structure whose
address is passed in the chain argument to the nested function.
But, in the above case, the c array is such a variable, but each thread is
supposed to have a private copy of that variable.

For C, this is a GNU extension and we can do whatever we want, including sorry.
For Fortran, nested functions can be only defined outside of BLOCK and when one
explicitly privatizes some variable, access to them from the nested functions
could be considered UB (like would be e.g. if in C/C++ one privatizes a
variable, but passes (shared or firstprivate or in some global variable)
address of the variable before being privatized and accesses that var through
the pointer).

Reply via email to