[Bug c++/126440] New: ICE when importing iostream after export import a module partition: in write_location, at cp/module.cc:18772

hxxu96 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=126440

            Bug ID: 126440
           Summary: ICE when importing iostream after export import a
                    module partition: in write_location, at
                    cp/module.cc:18772
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hxxu96 at gmail dot com
  Target Milestone: ---

The bug is confirmed in g++ 16.1.0 and 15.2.0.

$ cat list-node.cc

export module list:node;
export struct Node {};

$ cat list.cc

export module list;
export import :node;
import <iostream>;

$ cat build.sh

g++ -std=c++20 -fmodules-ts -Wall -g -x c++-system-header -c iostream
g++ -std=c++20 -fmodules-ts -Wall -g -x c++-system-header -c string
g++ -std=c++20 -fmodules-ts -Wall -g -c list-node.cc
g++ -std=c++20 -fmodules-ts -Wall -g -c list.cc -freport-bug


preprocessed source:

// Target: x86_64-linux-gnu
// Configured with: /usr/src/gcc/configure --build=x86_64-linux-gnu
--disable-multilib --enable-languages=c,c++,fortran,go
// Thread model: posix
// Supported LTO compression algorithms: zlib zstd
// gcc version 16.1.0 (GCC)
//
// list.cc:1:8: internal compiler error: in write_location, at
cp/module.cc:18772
//     1 | export module list;
//       |        ^~~~~~
// 0x2401276 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
//      ???:0
// 0x23fa23f internal_error(char const*, ...)
//      ???:0
// 0x7f646d fancy_abort(char const*, int, char const*)
//      ???:0
// 0x9429d8 module_state::write_cluster(elf_out*, depset**, unsigned int,
depset::hash&, unsigned int*, unsigned int*)
//      ???:0
// 0x944386 module_state::write_begin(elf_out*, cpp_reader*,
module_state_config&, unsigned int&)
//      ???:0
// 0x944eed finish_module_processing(cpp_reader*)
//      ???:0
// 0x8d45b3 c_parse_final_cleanups()
//      ???:0
// 0xb14b60 c_common_parse_file()
//      ???:0
// -quiet -imultiarch x86_64-linux-gnu -D_GNU_SOURCE list.cc -quiet -dumpbase
list.cc -dumpbase-ext .cc -mtune=generic -march=x86-64 -g -Wall -std=c++20
-fmodules -freport-bug -o - -frandom-seed=0 -fdump-noaddr
// Please submit a full bug report, with preprocessed source.
// Please include the complete backtrace with any bug report.
// See <https://gcc.gnu.org/bugs/> for instructions.

// /usr/local/libexec/gcc/x86_64-linux-gnu/16.1.0/cc1plus -quiet -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE list.cc -quiet -dumpbase list.cc -dumpbase-ext
.cc -mtune=generic -march=x86-64 -g -Wall -std=c++20 -fmodules -freport-bug -o
- -frandom-seed=0 -fdump-noaddr

# 0 "list.cc"
# 1 "/home//"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3
# 0 "<command-line>" 2
# 1 "list.cc"
export module list;
export import :node;
import "/usr/local/include/c++/16.1.0/iostream";
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.