Bug 104318 - [modules] ICE tsubst_copy, at cp/pt.c:16621
Summary: [modules] ICE tsubst_copy, at cp/pt.c:16621
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: c++-modules
  Show dependency treegraph
 
Reported: 2022-02-01 00:32 UTC by Matt Egeler
Modified: 2024-05-24 15:24 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Egeler 2022-02-01 00:32:52 UTC
Reproducible here with both 11.2 and trunk.

====foo_interface.ii=====================
# 0 "<built-in>"
# 1 "foo2.ipp"
module ;
# 1 "include1.h" 1
template <typename> void h(int a) { a; }
template <typename> struct d { virtual void e() { h<int>; } };
extern template struct d<int>;
template <typename> struct c;
template <typename = c<int>> struct b { d<int> f; };
template <> struct c<int> { void g() { b f; } };
# 3 "foo2.ipp" 2
export  module  mod;
b a;
====foo_implementation.ii=======================
# 0 "<built-in>"
# 1 "foo2.cpp"
module ;
# 1 "include2.h" 1
template <typename> void h(int);
template <typename> struct c { int static b; };
void b() { c<int>::b; }
# 3 "foo2.cpp" 2
module  mod;
====build========================================================
g++ -std=c++20 -fmodules-ts -c foo_interface.ii
g++ -std=c++20 -fmodules-ts -c foo_implementation.ii
====output========================================================
In file included from foo2.ipp:2,
of module mod, imported at foo2.cpp:3:
include1.h: In instantiation of ‘void h(int) [with <template-parameter-1-1> = int]’:
include1.h:2:51:   required from ‘void d@mod< <template-parameter-1-1> >::e() [with <template-parameter-1-1> = int]’
include1.h:2:45:   required from here
include1.h:1:37: internal compiler error: in tsubst_copy, at cp/pt.c:16621
    1 | template <typename> void h(int a) { a; }
      |                                     ^
0x1724b67 internal_error(char const*, ...)
	???:0
0x66b62d fancy_abort(char const*, int, char const*)
	???:0
0x7d05ff instantiate_decl(tree_node*, bool, bool)
	???:0
0x7ec25b instantiate_pending_templates(int)
	???:0
0x6fe518 c_parse_final_cleanups()
	???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

====
Alternative reproduction (with system includes)
====

====foo.ipp================================
module;
#include <bits/locale_classes.h>
#include <istream>
export module foobar;
std::string blah;
====foo.cpp============================
module;
#include <string>
module foobar;
====build============================================
g++ -x c++ -std=c++20 -fmodules-ts -c foo.ipp 
g++ -x c++ -std=c++20 -fmodules-ts -c foo.cpp
====output===========================================
In file included from /nix/store/ps9yrq46k74pi9dywn6k9sp7ygg2rwjv-gcc-11.2.0/include/c++/11.2.0/bits/locale_classes.h:857,
                 from foo.ipp:2,
of module foobar, imported at foo.cpp:3:
/nix/store/ps9yrq46k74pi9dywn6k9sp7ygg2rwjv-gcc-11.2.0/include/c++/11.2.0/bits/locale_classes.tcc: In instantiation of ‘const _Facet& std::use_facet(const std::locale&) [with _Facet = std::__cxx11::numpunct<char>]’:
/nix/store/ps9yrq46k74pi9dywn6k9sp7ygg2rwjv-gcc-11.2.0/include/c++/11.2.0/bits/locale_facets.tcc:80:66:   required from ‘void std::__numpunct_cache@foobar<_CharT>::_M_cache(const std::locale&) [with _CharT = char]’
/nix/store/ps9yrq46k74pi9dywn6k9sp7ygg2rwjv-gcc-11.2.0/include/c++/11.2.0/bits/locale_facets.tcc:63:18:   required from ‘const std::__numpunct_cache@foobar<_CharT>* std::__use_cache@foobar<std::__numpunct_cache@foobar<_CharT> >::operator()(const std::locale&) const [with _CharT = char]’
/nix/store/ps9yrq46k74pi9dywn6k9sp7ygg2rwjv-gcc-11.2.0/include/c++/11.2.0/bits/locale_facets.tcc:384:33:   required from ‘_InIter std::num_get<_CharT, _InIter>::_M_extract_int(_InIter, _InIter, std::ios_base&, std::ios_base::iostate&, _ValueT&) const [with _ValueT = long int; _CharT = char; _InIter = std::istreambuf_iterator<char, std::char_traits<char> >; std::ios_base::iostate = std::ios_base::iostate]’
/nix/store/ps9yrq46k74pi9dywn6k9sp7ygg2rwjv-gcc-11.2.0/include/c++/11.2.0/bits/locale_facets.h:2220:30:   required from ‘std::num_get<_CharT, _InIter>::iter_type std::num_get<_CharT, _InIter>::do_get(std::num_get<_CharT, _InIter>::iter_type, std::num_get<_CharT, _InIter>::iter_type, std::ios_base&, std::ios_base::iostate&, long int&) const [with _CharT = char; _InIter = std::istreambuf_iterator<char, std::char_traits<char> >; std::num_get<_CharT, _InIter>::iter_type = std::istreambuf_iterator<char, std::char_traits<char> >; std::ios_base::iostate = std::ios_base::iostate]’
/nix/store/ps9yrq46k74pi9dywn6k9sp7ygg2rwjv-gcc-11.2.0/include/c++/11.2.0/bits/locale_facets.h:2218:7:   required from here
/nix/store/ps9yrq46k74pi9dywn6k9sp7ygg2rwjv-gcc-11.2.0/include/c++/11.2.0/bits/locale_classes.tcc:135:40: internal compiler error: in tsubst_copy, at cp/pt.c:16621
  135 |       const locale::facet** __facets = __loc._M_impl->_M_facets;
      |                                        ^~~~~
0x1724b67 internal_error(char const*, ...)
	???:0
0x66b62d fancy_abort(char const*, int, char const*)
	???:0
0x7d05ff instantiate_decl(tree_node*, bool, bool)
	???:0
0x7ec25b instantiate_pending_templates(int)
	???:0
0x6fe518 c_parse_final_cleanups()
	???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.



$ gcc -v
Using built-in specs.
COLLECT_GCC=/nix/store/ps9yrq46k74pi9dywn6k9sp7ygg2rwjv-gcc-11.2.0/bin/gcc
COLLECT_LTO_WRAPPER=/nix/store/ps9yrq46k74pi9dywn6k9sp7ygg2rwjv-gcc-11.2.0/libexec/gcc/x86_64-unknown-linux-gnu/11.2.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: 
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (GCC)
Comment 1 Nathaniel Shead 2024-05-24 15:24:55 UTC
I can no longer reproduce (either reproducer) since GCC 14.