public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/103752] [12 Regression][ICE][modules] with import <string>
Date: Mon, 17 Jan 2022 13:13:27 +0000	[thread overview]
Message-ID: <bug-103752-4-nEEPWAv59a@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103752-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The problem seems to be explicit(bool), and it fails for gcc-11 too.

// header.h
template<typename _T1, typename _T2>
struct pair
{
        constexpr
      explicit(__is_same(_T1, _T2))
      pair()
      { }

        _T1 first;
        _T2 second;
};

struct string
{
  string() { }
  string(const char* s) : s(s) { }

  const char* s = "";
};

/home/jwakely/gcc/11/bin/g++ -std=c++2b -xc++-header header.h  -fmodules-ts


// crash.cpp
export module x;
import "header.h";
pair<string, string> environment;

/home/jwakely/gcc/11/bin/g++ -std=c++2b -c crash.cpp -fmodules-ts

In module ./header.h, imported at crash.cpp:2:
header.h: In instantiation of ‘struct pair<string, string>’:
crash.cpp:3:22:   required from here
header.h:6:7: internal compiler error: Segmentation fault
    6 |       pair()
      |       ^~~~
0xca8f1f crash_signal
        /home/jwakely/src/gcc/gcc-11/gcc/toplev.c:327
0x7fb52bd2d31f ???
        ../sysdeps/unix/sysv/linux/sigaction.c:670
0x7a3c23 hash_table_mod1(unsigned int, unsigned int)
        /home/jwakely/src/gcc/gcc-11/gcc/hash-table.h:344
0x7a3c23 hash_table<hash_map<tree_node*, tree_node*,
decl_tree_cache_traits>::hash_entry, false,
xcallocator>::find_with_hash(tree_node* const&, unsigned int)
        /home/jwakely/src/gcc/gcc-11/gcc/hash-table.h:911
0x7a3c23 hash_map<tree_node*, tree_node*,
decl_tree_cache_traits>::get(tree_node* const&)
        /home/jwakely/src/gcc/gcc-11/gcc/hash-map.h:185
0x7a3c23 lookup_explicit_specifier
        /home/jwakely/src/gcc/gcc-11/gcc/cp/pt.c:13782
0x7a3c23 tsubst_function_decl
        /home/jwakely/src/gcc/gcc-11/gcc/cp/pt.c:14007
0x799879 tsubst_decl
        /home/jwakely/src/gcc/gcc-11/gcc/cp/pt.c:14467
0x7ab3cc instantiate_class_template_1
        /home/jwakely/src/gcc/gcc-11/gcc/cp/pt.c:11997
0x7ac6a2 instantiate_class_template(tree_node*)
        /home/jwakely/src/gcc/gcc-11/gcc/cp/pt.c:12276
0x7de8db complete_type(tree_node*)
        /home/jwakely/src/gcc/gcc-11/gcc/cp/typeck.c:143
0x7de8db complete_type(tree_node*)
        /home/jwakely/src/gcc/gcc-11/gcc/cp/typeck.c:111
0x69c6eb start_decl_1(tree_node*, bool)
        /home/jwakely/src/gcc/gcc-11/gcc/cp/decl.c:5644
0x6ad5af start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        /home/jwakely/src/gcc/gcc-11/gcc/cp/decl.c:5610
0x76c443 cp_parser_init_declarator
        /home/jwakely/src/gcc/gcc-11/gcc/cp/parser.c:21763
0x74b124 cp_parser_simple_declaration
        /home/jwakely/src/gcc/gcc-11/gcc/cp/parser.c:14467
0x774e25 cp_parser_declaration
        /home/jwakely/src/gcc/gcc-11/gcc/cp/parser.c:14164
0x775afe cp_parser_toplevel_declaration
        /home/jwakely/src/gcc/gcc-11/gcc/cp/parser.c:14193
0x775afe cp_parser_translation_unit
        /home/jwakely/src/gcc/gcc-11/gcc/cp/parser.c:4942
0x775afe c_parse_file()
        /home/jwakely/src/gcc/gcc-11/gcc/cp/parser.c:45340
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.


The only reason you don't see it for gcc-11 is that <string> doesn't use
explicit(bool) until gcc-12.

I think the short answer for now is that compiling libstdc++ headers as header
units is not really supported.

  parent reply	other threads:[~2022-01-17 13:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16 17:14 [Bug c++/103752] New: " egor.pugin at gmail dot com
2021-12-16 21:14 ` [Bug c++/103752] " pinskia at gcc dot gnu.org
2022-01-17 12:53 ` rguenth at gcc dot gnu.org
2022-01-17 13:13 ` redi at gcc dot gnu.org [this message]
2022-02-09  2:25 ` jason at gcc dot gnu.org
2022-02-09 15:41 ` cvs-commit at gcc dot gnu.org
2022-02-09 15:41 ` jason at gcc dot gnu.org
2022-02-09 15:45 ` johelegp at gmail dot com
2022-02-09 16:32 ` johelegp at gmail dot com
2022-10-12 11:31 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103752-4-nEEPWAv59a@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).