public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99573] New: ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663
@ 2021-03-13 11:44 niancw29 at 163 dot com
  2021-03-30  1:13 ` [Bug c++/99573] " mpolacek at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: niancw29 at 163 dot com @ 2021-03-13 11:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99573
           Summary: ICE in module: internal compiler error: tree check:
                    expected class ‘type’, have ‘exceptional’ (error_mark)
                    in start_enum, at cp/decl.c:15663
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: niancw29 at 163 dot com
  Target Milestone: ---

Created attachment 50380
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50380&action=edit
obj-some-std.ii and obj-main.ii

There are two files:

// some-std.cc
export module A;
#include <string>

// main.cpp
import A;
int main(){}


I know it won't compile, but it introduces an ICE. Compiling with
--------------------------------------------------
g++ -fmodules-ts -std=c++20 some-std.cc main.cpp -o obj
--------------------------------------------------
then I reproduce it.
Here is the total output using "g++ -v":
--------------------------------------------------
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/11.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.1 20210308 (experimental) (GCC) 
--------------------------------------------------
In file included from /usr/local/include/c++/11.0.1/string:38,
                 from some-std.cc:3:
/usr/local/include/c++/11.0.1/bits/stl_iterator_base_funcs.h: In function
‘constexpr void std::__advance(_InputIterator&, _Distance,
std::input_iterator_tag)’:
/usr/local/include/c++/11.0.1/bits/stl_iterator_base_funcs.h:151:7: error:
block-scope extern declaration ‘void std::__failed_assertion()’ not permitted
in module purview
  151 |       __glibcxx_assert(__n >= 0);
      |       ^~~~~~~~~~~~~~~~
In file included from /usr/local/include/c++/11.0.1/bits/stl_iterator.h:81,
                 from /usr/local/include/c++/11.0.1/bits/stl_algobase.h:67,
                 from /usr/local/include/c++/11.0.1/bits/char_traits.h:39,
                 from /usr/local/include/c++/11.0.1/string:40,
                 from some-std.cc:3:
/usr/local/include/c++/11.0.1/new: At global scope:
/usr/local/include/c++/11.0.1/new:89:27: error: cannot define ‘enum class
std::align_val_t’ in different module
   89 |   enum class align_val_t: size_t {};
      |                           ^~~~~~
<built-in>: note: declared here
/usr/local/include/c++/11.0.1/new:89:27: internal compiler error: tree check:
expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at
cp/decl.c:15663
0x833681 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ../../gcc/gcc/tree.c:9864
0x66bb45 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        ../../gcc/gcc/tree.h:3476
0x66bb45 start_enum(tree_node*, tree_node*, tree_node*, tree_node*, bool,
bool*)
        ../../gcc/gcc/cp/decl.c:15663
0xa63207 cp_parser_enum_specifier
        ../../gcc/gcc/cp/parser.c:19965
0xa63207 cp_parser_type_specifier
        ../../gcc/gcc/cp/parser.c:18391
0xa63ef9 cp_parser_decl_specifier_seq
        ../../gcc/gcc/cp/parser.c:15041
0xa64cd1 cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.c:14298
0xa919d5 cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:14116
0xa91309 cp_parser_toplevel_declaration
        ../../gcc/gcc/cp/parser.c:14145
0xa91309 cp_parser_declaration_seq_opt
        ../../gcc/gcc/cp/parser.c:13933
0xa917a2 cp_parser_namespace_body
        ../../gcc/gcc/cp/parser.c:20433
0xa917a2 cp_parser_namespace_definition
        ../../gcc/gcc/cp/parser.c:20411
0xa91ef8 cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:14096
0xa91309 cp_parser_toplevel_declaration
        ../../gcc/gcc/cp/parser.c:14145
0xa91309 cp_parser_declaration_seq_opt
        ../../gcc/gcc/cp/parser.c:13933
0xa92c85 cp_parser_linkage_specification
        ../../gcc/gcc/cp/parser.c:15309
0xa91aea cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:14035
0xa9274c cp_parser_toplevel_declaration
        ../../gcc/gcc/cp/parser.c:14145
0xa9274c cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:4936
0xa9274c c_parse_file()
        ../../gcc/gcc/cp/parser.c:45231
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.
--------------------------------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/99573] ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663
  2021-03-13 11:44 [Bug c++/99573] New: ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663 niancw29 at 163 dot com
@ 2021-03-30  1:13 ` mpolacek at gcc dot gnu.org
  2021-03-30  1:17 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-30  1:13 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|                            |2021-03-30
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.  I hit this with another, simplified example:

// x.h
namespace std {
  enum class align_val_t: decltype(sizeof(int)) {};
}

// z.cc
export module A:base;
#include "x.h"

$ ./cc1plus -quiet z.cc -fmodules-ts
In file included from z.cc:2:
x.h:2:27: error: cannot define ‘enum class std::align_val_t’ in different
module
    2 |   enum class align_val_t: decltype(sizeof(int)) {};
      |                           ^~~~~~~~~~~~~~~~~~~~~
<built-in>: note: declared here
x.h:2:27: internal compiler error: tree check: expected class ‘type’, have
‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15699
0x1a18873 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        /home/mpolacek/src/gcc/gcc/tree.c:9866
0xa1e03c tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        /home/mpolacek/src/gcc/gcc/tree.h:3476
0xb4d2e1 start_enum(tree_node*, tree_node*, tree_node*, tree_node*, bool,
bool*)
        /home/mpolacek/src/gcc/gcc/cp/decl.c:15699
0xc9a49d cp_parser_enum_specifier
        /home/mpolacek/src/gcc/gcc/cp/parser.c:19986
0xc9725b cp_parser_type_specifier
        /home/mpolacek/src/gcc/gcc/cp/parser.c:18412
0xc91963 cp_parser_decl_specifier_seq
        /home/mpolacek/src/gcc/gcc/cp/parser.c:15062
0xc90054 cp_parser_simple_declaration
        /home/mpolacek/src/gcc/gcc/cp/parser.c:14319
0xc8ffdc cp_parser_block_declaration
        /home/mpolacek/src/gcc/gcc/cp/parser.c:14266
0xc8fca8 cp_parser_declaration
        /home/mpolacek/src/gcc/gcc/cp/parser.c:14137
0xc8fd9d cp_parser_toplevel_declaration
        /home/mpolacek/src/gcc/gcc/cp/parser.c:14166
0xc8f53e cp_parser_declaration_seq_opt
        /home/mpolacek/src/gcc/gcc/cp/parser.c:13954
0xc9b41c cp_parser_namespace_body
        /home/mpolacek/src/gcc/gcc/cp/parser.c:20454
0xc9b3c5 cp_parser_namespace_definition
        /home/mpolacek/src/gcc/gcc/cp/parser.c:20432
0xc8fb8d cp_parser_declaration
        /home/mpolacek/src/gcc/gcc/cp/parser.c:14117
0xc8fd9d cp_parser_toplevel_declaration
        /home/mpolacek/src/gcc/gcc/cp/parser.c:14166
0xc7b6e5 cp_parser_translation_unit
        /home/mpolacek/src/gcc/gcc/cp/parser.c:4942
0xcde6f6 c_parse_file()
        /home/mpolacek/src/gcc/gcc/cp/parser.c:45257
0xea11b4 c_common_parse_file()
        /home/mpolacek/src/gcc/gcc/c-family/c-opts.c:1218

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/99573] ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663
  2021-03-13 11:44 [Bug c++/99573] New: ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663 niancw29 at 163 dot com
  2021-03-30  1:13 ` [Bug c++/99573] " mpolacek at gcc dot gnu.org
@ 2021-03-30  1:17 ` mpolacek at gcc dot gnu.org
  2024-02-14 11:06 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-30  1:17 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-valid-code           |ice-on-invalid-code

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Original test:

export module A:base;
#include <string>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/99573] ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663
  2021-03-13 11:44 [Bug c++/99573] New: ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663 niancw29 at 163 dot com
  2021-03-30  1:13 ` [Bug c++/99573] " mpolacek at gcc dot gnu.org
  2021-03-30  1:17 ` mpolacek at gcc dot gnu.org
@ 2024-02-14 11:06 ` cvs-commit at gcc dot gnu.org
  2024-02-14 11:08 ` nshead at gcc dot gnu.org
  2024-03-11 21:21 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-14 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:

https://gcc.gnu.org/g:bbb30f12a7e5ce008f59ec26c9e4cc65ee79fe56

commit r14-8974-gbbb30f12a7e5ce008f59ec26c9e4cc65ee79fe56
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date:   Mon Feb 12 12:40:15 2024 +1100

    c++: Fix error recovery when redeclaring enum in different module [PR99573]

    This ensures that with modules enabled, redeclaring an enum in the wrong
    module or with the wrong underlying type no longer ICEs.

    The patch also rearranges the order of the checks a little because I
    think it's probably more important to note that you can't redeclare the
    enum all before complaining about mismatched underlying types etc.

    As a drive by this patch also adds some missing diagnostic groups, and
    rewords the module redeclaration error message to more closely match the
    wording used in other places this check is done.

            PR c++/99573

    gcc/cp/ChangeLog:

            * decl.cc (start_enum): Reorder check for redeclaring in module.
            Add missing auto_diagnostic_groups.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/enum-12.C: New test.

    Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
    Reviewed-by: Jason Merrill <jason@redhat.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/99573] ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663
  2021-03-13 11:44 [Bug c++/99573] New: ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663 niancw29 at 163 dot com
                   ` (2 preceding siblings ...)
  2024-02-14 11:06 ` cvs-commit at gcc dot gnu.org
@ 2024-02-14 11:08 ` nshead at gcc dot gnu.org
  2024-03-11 21:21 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-02-14 11:08 UTC (permalink / raw)
  To: gcc-bugs

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

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |error-recovery
           Assignee|unassigned at gcc dot gnu.org      |nshead at gcc dot gnu.org
   Target Milestone|---                         |14.0
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
                 CC|                            |nshead at gcc dot gnu.org

--- Comment #4 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Fixed for GCC 14.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/99573] ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663
  2021-03-13 11:44 [Bug c++/99573] New: ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663 niancw29 at 163 dot com
                   ` (3 preceding siblings ...)
  2024-02-14 11:08 ` nshead at gcc dot gnu.org
@ 2024-03-11 21:21 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-03-11 21:21 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |unlvsur at live dot com

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 101093 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-11 21:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-13 11:44 [Bug c++/99573] New: ICE in module: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in start_enum, at cp/decl.c:15663 niancw29 at 163 dot com
2021-03-30  1:13 ` [Bug c++/99573] " mpolacek at gcc dot gnu.org
2021-03-30  1:17 ` mpolacek at gcc dot gnu.org
2024-02-14 11:06 ` cvs-commit at gcc dot gnu.org
2024-02-14 11:08 ` nshead at gcc dot gnu.org
2024-03-11 21:21 ` ppalka at gcc dot gnu.org

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).