[Bug c++/126835] New: ICE on templated #pragma omp declare mapper with -fopenmp-simd

"s.kimura.h41104 at gmail dot com via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126835

            Bug ID: 126835
           Summary: ICE on templated #pragma omp declare mapper with
                    -fopenmp-simd
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: s.kimura.h41104 at gmail dot com
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/5Wz7b3xqb

Reproducer:
```
struct S {};

template <typename T> void foo() {
  int y;
#pragma omp declare mapper(T var) map(always, to : var, y)
}

void bar() { foo<S>(); }
```

Backtrace:
<source>: In instantiation of 'void foo() [with T = S]':
<source>:8:20:   required from here
    8 | void bar() { foo<S>(); }
      |              ~~~~~~^~
<source>:5:30: internal compiler error: in copy_linkage, at cp/decl2.cc:4078
    5 | #pragma omp declare mapper(T var) map(always, to : var, y)
      |                              ^~~
0x2bae358 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2ba2f9b internal_error(char const*, ...)
        ???:0
0xb427ee fancy_abort(char const*, int, char const*)
        ???:0
0xc61b8c get_guard(tree_node*)
        ???:0
0xc5444f cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0xdfd61d instantiate_decl(tree_node*, bool, bool)
        ???:0
0xe0750a instantiate_pending_templates(int)
        ???:0
0xc68fd8 c_parse_final_cleanups()
        ???:0
0xf2b998 c_common_parse_file()
        ???:0


This ICE goes back to gcc-16:
https://godbolt.org/z/djWK8s7aT
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.