public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "davidfromonline at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/112355] New: Internal compiler error when exporting using declaration of function template
Date: Thu, 02 Nov 2023 19:01:19 +0000	[thread overview]
Message-ID: <bug-112355-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 112355
           Summary: Internal compiler error when exporting using
                    declaration of function template
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: davidfromonline at gmail dot com
  Target Milestone: ---

The following mostly valid code:

```cxx
module;

namespace n {

template<typename T>
void f() {
}

}

export module m;

export using n::f;
```

causes gcc to crash with

```console
<source>:3:1: error: global module fragment contents must be from preprocessor
inclusion
    3 | namespace n {
      | ^~~~~~~~~
<source>:13:17: internal compiler error: tree check: expected none of
template_decl, have template_decl in do_nonmember_using_decl, at
cp/name-lookup.cc:4853
   13 | export using n::f;
      |                 ^
0x8fbb6e tree_not_check_failed(tree_node const*, char const*, int, char const*,
...)
        gcc/source/gcc/tree.cc:8986
0x76f1d4 tree_not_check(tree_node*, char const*, int, char const*, tree_code)
        gcc/source/gcc/tree.h:3607
0x76f1d4 do_nonmember_using_decl
        gcc/source/gcc/cp/name-lookup.cc:4853
0xb63549 finish_nonmember_using_decl(tree_node*, tree_node*)
        gcc/source/gcc/cp/name-lookup.cc:6297
0xb6d974 finish_using_decl
        gcc/source/gcc/cp/parser.cc:21908
0xbb482f cp_parser_using_declaration
        gcc/source/gcc/cp/parser.cc:22072
0xbc8653 cp_parser_declaration
        gcc/source/gcc/cp/parser.cc:15335
0xbc85d4 cp_parser_module_export
        gcc/source/gcc/cp/parser.cc:15080
0xbc85d4 cp_parser_declaration
        gcc/source/gcc/cp/parser.cc:15276
0xbc908a cp_parser_toplevel_declaration
        gcc/source/gcc/cp/parser.cc:15356
0xbc908a cp_parser_translation_unit
        gcc/source/gcc/cp/parser.cc:5218
0xbc908a c_parse_file()
        gcc/source/gcc/cp/parser.cc:50627
0xd0f8e1 c_common_parse_file()
        gcc/source/gcc/c-family/c-opts.cc:1278
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

See it live: http://desktop:10240/z/nj5q1b

(the crash still exists if the global module fragment comes from an #include, I
just made it this way to have a single-file reproduction)

             reply	other threads:[~2023-11-02 19:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 19:01 davidfromonline at gmail dot com [this message]
2023-11-02 19:03 ` [Bug c++/112355] " davidfromonline at gmail dot com
2023-11-02 19:03 ` pinskia at gcc dot gnu.org
2023-11-02 19:04 ` pinskia 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-112355-4@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).