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

            Bug ID: 119864
           Summary: [modules] ICE -fmodules and omp reduction of UDT
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pilarlatiesa at gmail dot com
  Target Milestone: ---

$ cat p1.cpp 

export module p1;

export
template<unsigned>
struct T
{
  double d;

  T &operator +=(T const &x) { d += x.d; return *this; }
};

export
template<unsigned d>
T<d> sum(T<d> const *p, unsigned N)
{
T<d> Sum = {};

#pragma omp declare reduction(Op: T<d>: omp_out += omp_in) initializer(omp_priv
= {})
#pragma omp parallel for reduction(Op: Sum)
for (unsigned i = 0u; i < N; ++i)
  {
  Sum += *p;
  ++p;
  }
return Sum;
}

$ ~/gcc-15/bin/g++ -std=c++20 -fmodules -fopenmp -c p1.cpp -fmodule-only

$ cat main.cpp 

import p1;

int main()
{
  T<1u> v[3u] = {};

  T s = sum(v, 3u);

}

$ ~/gcc-15/bin/g++ -std=c++20 -fmodules -fopenmp -freport-bug -c main.cpp 
main.cpp: In function ‘void omp declare reduction Op(T@p1<d>&)’:
main.cpp:8:9: error interno del compilador: Violación de segmento
    8 |   T s = sum(v, 3u);
      |         ^~~
0x22373d6 internal_error(char const*, ...)
        ../../gcc-15.1.0-RC-20250418/gcc/diagnostic-global-context.cc:517
0xf8a223 crash_signal
        ../../gcc-15.1.0-RC-20250418/gcc/toplev.cc:322
0x77463624532f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xf7b946 relayout_decl(tree_node*)
        ../../gcc-15.1.0-RC-20250418/gcc/stor-layout.cc:854
0xc1caee allocate_struct_function(tree_node*, bool)
        ../../gcc-15.1.0-RC-20250418/gcc/function.cc:4882
0x8a6c87 module_state::read_cluster(unsigned int)
        ../../gcc-15.1.0-RC-20250418/gcc/cp/module.cc:16705
0x8a739d module_state::load_section(unsigned int, binding_slot*)
        ../../gcc-15.1.0-RC-20250418/gcc/cp/module.cc:20217
0x8a754e lazy_load_binding(unsigned int, tree_node*, tree_node*, binding_slot*)
        ../../gcc-15.1.0-RC-20250418/gcc/cp/module.cc:21100
0x8ba57d name_lookup::search_namespace_only(tree_node*)
        ../../gcc-15.1.0-RC-20250418/gcc/cp/name-lookup.cc:929
0x8bbbf3 name_lookup::search_unqualified(tree_node*, cp_binding_level*)
        ../../gcc-15.1.0-RC-20250418/gcc/cp/name-lookup.cc:1159
0x8bdcae lookup_name(tree_node*, LOOK_where, LOOK_want)
        ../../gcc-15.1.0-RC-20250418/gcc/cp/name-lookup.cc:8121
0x8cd182 lookup_name(tree_node*, LOOK_want)
        ../../gcc-15.1.0-RC-20250418/gcc/cp/name-lookup.h:410
0x8cd182 cp_parser_lookup_name
        ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:32997
0x90f17a cp_parser_class_name
        ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:27374
0x90f49c cp_parser_type_name
        ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:21464
0x90487e cp_parser_simple_type_specifier
        ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:21157
0x9064ac cp_parser_postfix_expression
        ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:8158
0x902ec8 cp_parser_unary_expression
        ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:9733
0x8d726a cp_parser_cast_expression
        ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:10648
0x8d807b cp_parser_binary_expression
        ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:10751
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
Véase <https://gcc.gnu.org/bugs/> para instrucciones.


$ cat /tmp/ccKxMTkW.out 
// Objetivo: x86_64-pc-linux-gnu
// Configurado con: ../gcc-15.1.0-RC-20250418/configure --disable-multilib
--disable-bootstrap --enable-languages=c++ --prefix=/home/pililatiesa/gcc-15/
// Modelo de hilos: posix
// Algoritmos de compresión LTO admitidos: zlib zstd
// gcc versión 15.0.1 20250418 (prerelease) (GCC) 
// 
// main.cpp: In function ‘void omp declare reduction Op(T@p1<d>&)’:
// main.cpp:8:9: error interno del compilador: Violación de segmento
//     8 |   T s = sum(v, 3u);
//       |         ^~~
// 0x22373d6 internal_error(char const*, ...)
//      ../../gcc-15.1.0-RC-20250418/gcc/diagnostic-global-context.cc:517
// 0xf8a223 crash_signal
//      ../../gcc-15.1.0-RC-20250418/gcc/toplev.cc:322
// 0x7ffff7a4532f ???
//      ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
// 0xf7b946 relayout_decl(tree_node*)
//      ../../gcc-15.1.0-RC-20250418/gcc/stor-layout.cc:854
// 0xc1caee allocate_struct_function(tree_node*, bool)
//      ../../gcc-15.1.0-RC-20250418/gcc/function.cc:4882
// 0x8a6c87 module_state::read_cluster(unsigned int)
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/module.cc:16705
// 0x8a739d module_state::load_section(unsigned int, binding_slot*)
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/module.cc:20217
// 0x8a754e lazy_load_binding(unsigned int, tree_node*, tree_node*,
binding_slot*)
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/module.cc:21100
// 0x8ba57d name_lookup::search_namespace_only(tree_node*)
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/name-lookup.cc:929
// 0x8bbbf3 name_lookup::search_unqualified(tree_node*, cp_binding_level*)
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/name-lookup.cc:1159
// 0x8bdcae lookup_name(tree_node*, LOOK_where, LOOK_want)
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/name-lookup.cc:8121
// 0x8cd182 lookup_name(tree_node*, LOOK_want)
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/name-lookup.h:410
// 0x8cd182 cp_parser_lookup_name
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:32997
// 0x90f17a cp_parser_class_name
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:27374
// 0x90f49c cp_parser_type_name
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:21464
// 0x90487e cp_parser_simple_type_specifier
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:21157
// 0x9064ac cp_parser_postfix_expression
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:8158
// 0x902ec8 cp_parser_unary_expression
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:9733
// 0x8d726a cp_parser_cast_expression
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:10648
// 0x8d807b cp_parser_binary_expression
//      ../../gcc-15.1.0-RC-20250418/gcc/cp/parser.cc:10751
// Please submit a full bug report, with preprocessed source.
// Please include the complete backtrace with any bug report.
// Véase <https://gcc.gnu.org/bugs/> para instrucciones.

// /home/pililatiesa/gcc-15/libexec/gcc/x86_64-pc-linux-gnu/15.0.1/cc1plus
-quiet -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D_REENTRANT main.cpp -quiet
-dumpbase main.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -std=c++20
-fmodules -fopenmp -freport-bug -o - -frandom-seed=0 -fdump-noaddr

# 0 "main.cpp"
# 0 "<interno>"
# 0 "<línea-de-órdenes>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<línea-de-órdenes>" 2
# 1 "main.cpp"

import p1;

int main()
{
  T<1u> v[3u] = {};

  T s = sum(v, 3u);

}

Reply via email to