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

            Bug ID: 122748
           Summary: [OpenMP] ICE segfault with invalid 'allocate' clause
                    in c_parser_omp_clause_allocate at c-parser.cc:19348
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code, openmp
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

The following code is fine with '#include <omp.h>' but as there isn't, which
leads to an ICE. C++ seems to be fine, only C has that issue.

It only shows here with mainline, but I assume that's because of a checking
assert.

* * *

foo.c: In function ‘f’:
foo.c:4:38: error: ‘omp_default_mem_alloc’ undeclared (first use in this
function)
    4 |   #pragma omp taskloop simd allocate(omp_default_mem_alloc: a)
private(a)
      |                                      ^~~~~~~~~~~~~~~~~~~~~
foo.c:4:38: note: each undeclared identifier is reported only once for each
function it appears in


... OK – but then the ICE ...


foo.c:4:11: internal compiler error: tree check: expected class ‘type’, have
‘exceptional’ (error_mark) in c_parser_omp_clause_allocate, at
c/c-parser.cc:19348


Here, expr.original_type = NULL and ...

19346             orig_type = expr.original_type
19347                         ? expr.original_type : TREE_TYPE (allocator);
19348             orig_type = TYPE_MAIN_VARIANT (orig_type);

(gdb) p debug_tree(allocator)
 <error_mark 0x7ffff7402f48>

and (after line 19347, before line 19348):

(gdb) p debug_tree(orig_type)
 <error_mark 0x7ffff7402f48>

----------------------------------------
void f()
{
  int a;
  #pragma omp taskloop simd allocate(omp_default_mem_alloc: a) private(a)
  for(int i =0; i < 1; i++)
   a = 5;
}

Reply via email to