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

            Bug ID: 127829
           Summary: [15/16/17 Regression] [OpenMP] dispatch parser seems
                    to misidentify calls, sometimes badly enough to ICE
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

struct R { int x; };
R vr ();
#pragma omp declare variant (vr) match (construct={dispatch})
R fr ();

void t8a ()
{
  #pragma omp dispatch
  fr ();
}

void t8b ()
{
  R r;
  #pragma omp dispatch
  r = fr ();
}

template <class>
void t8c ()
{
  #pragma omp dispatch
  fr ();
}
template void t8c<int> ();

The following gives these errors on trunk with -fopenmp:

<source>: In function 'void t8a()':
<source>:9:8: error: expected '=' before ';' token
    9 |   fr ();
      |        ^
<source>:9:3: note: '#pragma omp dispatch' must be followed by a direct
function call with optional assignment
    9 |   fr ();
      |   ^~
<source>: In function 'void t8b()':
<source>:16:10: error: expected target-function call
   16 |   r = fr ();
      |       ~~~^~
<source>:16:3: note: '#pragma omp dispatch' must be followed by a direct
function call with optional assignment
   16 |   r = fr ();
      |   ^
<source>: In function 'void t8c() [with <template-parameter-1-1> = int]':
<source>:22:11: internal compiler error: in get_callee_fndecl, at tree.cc:8851
   22 |   #pragma omp dispatch
      |           ^~~
0x2c5b2b8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2c4fefb internal_error(char const*, ...)
        ???:0
0xb9d350 fancy_abort(char const*, int, char const*)
        ???:0
0x12912b3 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0x129cd06 gimplify_body(tree_node*, bool)
        ???:0
0x129d1cc gimplify_function_tree(tree_node*)
        ???:0
0x1063a47 cgraph_node::analyze()
        ???:0
0x1066f16 symbol_table::finalize_compilation_unit()
        ???:0
/cefs/59/59b1013b64ba01a4f1ea4290_gcc-trunk-20261011/bin/../libexec/gcc/x86_64-linux-gnu/17.0.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/59/59b1013b64ba01a4f1ea4290_gcc-trunk-20261011/bin/../lib/gcc/x86_64-linux-gnu/17.0.0/
-D_GNU_SOURCE -D_REENTRANT <source> -quiet -dumpdir /app/ -dumpbase output.cpp
-dumpbase-ext .cpp -masm=intel -mtune=generic -march=x86-64 -g -O2
-pedantic-errors -std=c++20 -fdiagnostics-color=always -fno-verbose-asm
-fchecking -fopenmp -fopenacc -o /app/output.s
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

GCC 16 and 15 have a similar issue - 14 and earlier does not support dispatch
(but at least doesn't crash, I suppose).

The cause is somewhat hard for me to understand - it seems like perhaps the
fact the dispatch parser (cp_parser_omp_dispatch_body) identifies "the call" by
its tree code ends up just being plain wrong?

Reply via email to