https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125377
Bug ID: 125377
Summary: [OpenMP] ICE tree check for invalid 'begin declare
variant'
Product: gcc
Version: 17.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 gives an ICE with:
/dev/shm/foo.c:11:23: error: multiple definitions of variants with the same
context selector violate the one-definition rule
11 | static inline int omp_is_initial_device(void) { return 1; }
| ^~~~~~~~~~~~~~~~~~~~~
/dev/shm/foo.c:58:1: internal compiler error: tree check: expected tree that
contains ‘decl minimal’ structure, have ‘identifier_node’ in
omp_check_for_duplicate_variant, at omp-general.cc:1565
58 | }
| ^
0x27e4faf internal_error(char const*, ...)
../../../repos/gcc-trunk-commit/gcc/diagnostic-global-context.cc:787
0x93de8e tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
../../../repos/gcc-trunk-commit/gcc/tree.cc:9393
0x888be4 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
../../../repos/gcc-trunk-commit/gcc/tree.h:3933
0x888be4 omp_check_for_duplicate_variant(unsigned long, tree_node*, tree_node*)
../../../repos/gcc-trunk-commit/gcc/omp-general.cc:1565
0xb28b46 omp_finish_variant_function
../../../repos/gcc-trunk-commit/gcc/c/c-parser.cc:28605
0xb28b46 c_parser_translation_unit
../../../repos/gcc-trunk-commit/gcc/c/c-parser.cc:2137
------------- cut -------------
#pragma omp begin declare variant match(device={kind(host)})
static inline int omp_is_initial_device(void) { return 1; }
#pragma omp end declare variant
#pragma omp begin declare variant match(device={kind(host)})
static inline int omp_is_initial_device(void) { return 1; }
#pragma omp end declare variant
int main()
{
__builtin_printf("%d\n", omp_is_initial_device());
}