https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118927
Bug ID: 118927 Summary: "double free detected in tcache 2" with import std and -Q Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nate at thatsmathematics dot com Target Milestone: --- Created attachment 60523 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60523&action=edit Main source file foo.cc I was trying to use gcc 15 trunk (commit 101e3101e) on arm64 gentoo (vm on Apple M3) to compile the following code from a recent article by Stroustrup (https://cacm.acm.org/blogcacm/21st-century-c/): import std; // make all of the standard library available using namespace std; int main() // print unique lines from input { unordered_map<string,int> m; // hash table for (string line; getline (cin,line); ) if (m[line]++ == 0) cout<<line<<'\n'; } Following the suggestion at https://stackoverflow.com/questions/76154680/how-to-use-module-std-with-gcc, I used g++ -Q -std=c++20 -fmodules -fsearch-include-path bits/std.cc foo.cc The compile fails with "free(): double free detected in tcache 2" and the following backtrace: 0x259e35b internal_error(char const*, ...) ../../gcc/diagnostic-global-context.cc:517 0x12a617b crash_signal ../../gcc/toplev.cc:322 0xb54343 cxx_printable_name_internal ../../gcc/cp/tree.cc:2768 0x12a6a3f announce_function(tree_node*) ../../gcc/toplev.cc:230 0x8ddd03 start_preparsed_function(tree_node*, tree_node*, int) ../../gcc/cp/decl.cc:18590 0x9feb17 maybe_clone_body(tree_node*) ../../gcc/cp/optimize.cc:585 0x9a8f87 post_load_processing ../../gcc/cp/module.cc:18834 0x9d81ef lazy_load_pendings(tree_node*) ../../gcc/cp/module.cc:20769 0xabd3a7 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int) ../../gcc/cp/pt.cc:10241 0xac04cf tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc/cp/pt.cc:16549 0xac08bf tsubst_entering_scope ../../gcc/cp/pt.cc:10095 0xac08bf tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc/cp/pt.cc:17092 0x93ea8f dump_template_bindings ../../gcc/cp/error.cc:596 0x933b6f dump_function_decl ../../gcc/cp/error.cc:1982 0x93fb27 decl_as_string(tree_node*, int) ../../gcc/cp/error.cc:3334 0x93fb27 lang_decl_name(tree_node*, int, bool) ../../gcc/cp/error.cc:3369 0xb5435b cxx_printable_name_internal ../../gcc/cp/tree.cc:2770 0x12a6a3f announce_function(tree_node*) ../../gcc/toplev.cc:230 0x8ddd03 start_preparsed_function(tree_node*, tree_node*, int) ../../gcc/cp/decl.cc:18590 0x9feb17 maybe_clone_body(tree_node*) ../../gcc/cp/optimize.cc:585 When -Q is omitted, the program compiles and runs correctly. g++ -v output: Using built-in specs. COLLECT_GCC=/home/nate/do-not-backup/gcc-inst/bin/g++ COLLECT_LTO_WRAPPER=/home/nate/do-not-backup/gcc-inst/libexec/gcc/aarch64-unknown-linux-gnu/15.0.1/lto-wrapper Target: aarch64-unknown-linux-gnu Configured with: ../configure --enable-checking --enable-languages=c++ --prefix=/home/nate/do-not-backup/gcc-inst Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 15.0.1 20250218 (experimental) (GCC)