public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96462] New: [10/11 Regression] ICE in tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97
@ 2020-08-04 16:00 haoxintu at gmail dot com
  2020-08-04 16:03 ` [Bug c++/96462] " mpolacek at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: haoxintu at gmail dot com @ 2020-08-04 16:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96462
           Summary: [10/11 Regression] ICE in  tree check: expected
                    identifier_node, have bit_not_expr in
                    find_namespace_slot, at cp/name-lookup.c:97
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

This code makes GCC-trunk ICE without emitting any error messages, while other
released versions compile it well.

Input:
//small.cc
enum a {};
using a:: ~ a;

Command:
g++ small.cc

Output:
small.cc:2:13: internal compiler error: tree check: expected identifier_node,
have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97
    2 | using a:: ~ a;
      |             ^
0x7c7fd7 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/tree.c:9687
0x63f701 tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc/tree.h:3303
0x63f701 find_namespace_slot
        ../../gcc/cp/name-lookup.c:97
0x983071 name_lookup::search_namespace_only(tree_node*)
        ../../gcc/cp/name-lookup.c:544
0x983132 name_lookup::search_namespace(tree_node*)
        ../../gcc/cp/name-lookup.c:561
0x983132 name_lookup::search_namespace(tree_node*)
        ../../gcc/cp/name-lookup.c:554
0x983226 name_lookup::search_qualified(tree_node*, bool)
        ../../gcc/cp/name-lookup.c:622
0x983226 name_lookup::search_qualified(tree_node*, bool)
        ../../gcc/cp/name-lookup.c:614
0x986a1b qualified_namespace_lookup
        ../../gcc/cp/name-lookup.c:6045
0x986b8d lookup_using_decl
        ../../gcc/cp/name-lookup.c:4619
0x987070 finish_nonmember_using_decl(tree_node*, tree_node*)
        ../../gcc/cp/name-lookup.c:5132
0x9c7fd2 cp_parser_using_declaration
        ../../gcc/cp/parser.c:20025
0x9d763e cp_parser_declaration
        ../../gcc/cp/parser.c:13510
0x9d7d2b cp_parser_translation_unit
        ../../gcc/cp/parser.c:4793
0x9d7d2b c_parse_file()
        ../../gcc/cp/parser.c:44081
0xaf2e9d c_common_parse_file()
        ../../gcc/c-family/c-opts.c:1188
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.

My GCC version is
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure
--prefix=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/
--enable-languages=c,c++ CC=gcc CXX=g++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200801 (experimental) (GCC)

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

* [Bug c++/96462] [10/11 Regression] ICE in  tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97
  2020-08-04 16:00 [Bug c++/96462] New: [10/11 Regression] ICE in tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97 haoxintu at gmail dot com
@ 2020-08-04 16:03 ` mpolacek at gcc dot gnu.org
  2020-08-04 16:09 ` haoxintu at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-08-04 16:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Target Milestone|---                         |10.3
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2020-08-04

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/96462] [10/11 Regression] ICE in  tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97
  2020-08-04 16:00 [Bug c++/96462] New: [10/11 Regression] ICE in tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97 haoxintu at gmail dot com
  2020-08-04 16:03 ` [Bug c++/96462] " mpolacek at gcc dot gnu.org
@ 2020-08-04 16:09 ` haoxintu at gmail dot com
  2020-10-12 12:40 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: haoxintu at gmail dot com @ 2020-08-04 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Haoxin Tu <haoxintu at gmail dot com> ---
(In reply to Marek Polacek from comment #1)
> Confirmed.

Hi, Marek. Thanks for your quick response!

Best,
Haoxin

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

* [Bug c++/96462] [10/11 Regression] ICE in  tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97
  2020-08-04 16:00 [Bug c++/96462] New: [10/11 Regression] ICE in tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97 haoxintu at gmail dot com
  2020-08-04 16:03 ` [Bug c++/96462] " mpolacek at gcc dot gnu.org
  2020-08-04 16:09 ` haoxintu at gmail dot com
@ 2020-10-12 12:40 ` rguenth at gcc dot gnu.org
  2021-02-04  2:31 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-12 12:40 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/96462] [10/11 Regression] ICE in  tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97
  2020-08-04 16:00 [Bug c++/96462] New: [10/11 Regression] ICE in tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97 haoxintu at gmail dot com
                   ` (2 preceding siblings ...)
  2020-10-12 12:40 ` rguenth at gcc dot gnu.org
@ 2021-02-04  2:31 ` mpolacek at gcc dot gnu.org
  2021-02-04  2:41 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-04  2:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r271467.

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

* [Bug c++/96462] [10/11 Regression] ICE in  tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97
  2020-08-04 16:00 [Bug c++/96462] New: [10/11 Regression] ICE in tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97 haoxintu at gmail dot com
                   ` (3 preceding siblings ...)
  2021-02-04  2:31 ` mpolacek at gcc dot gnu.org
@ 2021-02-04  2:41 ` mpolacek at gcc dot gnu.org
  2021-02-04  2:46 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-04  2:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Probably can be fixed with just

--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -5702,6 +5702,13 @@ lookup_using_decl (tree scope, name_lookup &lookup)

   if (TREE_CODE (scope) == NAMESPACE_DECL)
     {
+      /* You cannot using-decl a destructor.  */
+      if (TREE_CODE (lookup.name) == BIT_NOT_EXPR)
+   {
+     error ("using-declaration cannot name a destructor");
+     return NULL_TREE;
+   }
+
       /* Naming a namespace member.  */
       qualified_namespace_lookup (scope, &lookup);

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

* [Bug c++/96462] [10/11 Regression] ICE in  tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97
  2020-08-04 16:00 [Bug c++/96462] New: [10/11 Regression] ICE in tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97 haoxintu at gmail dot com
                   ` (4 preceding siblings ...)
  2021-02-04  2:41 ` mpolacek at gcc dot gnu.org
@ 2021-02-04  2:46 ` mpolacek at gcc dot gnu.org
  2021-02-05 16:07 ` cvs-commit at gcc dot gnu.org
  2021-02-05 16:08 ` [Bug c++/96462] [10 " mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-04  2:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug c++/96462] [10/11 Regression] ICE in  tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97
  2020-08-04 16:00 [Bug c++/96462] New: [10/11 Regression] ICE in tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97 haoxintu at gmail dot com
                   ` (5 preceding siblings ...)
  2021-02-04  2:46 ` mpolacek at gcc dot gnu.org
@ 2021-02-05 16:07 ` cvs-commit at gcc dot gnu.org
  2021-02-05 16:08 ` [Bug c++/96462] [10 " mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-05 16:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:1cbc10d894494c34987d1f42f955e7843457ee38

commit r11-7125-g1cbc10d894494c34987d1f42f955e7843457ee38
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Feb 4 12:53:59 2021 -0500

    c++: Fix ICE with invalid using enum [PR96462]

    Here we ICE in finish_nonmember_using_decl -> lookup_using_decl ->
    ... -> find_namespace_slot because "name" is not an IDENTIFIER_NODE.
    It is a BIT_NOT_EXPR because this broken test uses

      using E::~E; // SCOPE::NAME

    A using-decl can't refer to a destructor, and lookup_using_decl already
    checks that in the class member case.  But in C++17, we do the "enum
    scope is the enclosing scope" block, and so scope gets set to ::, and
    we go into the NAMESPACE_DECL block.  In C++20 we don't do it, we go
    to the ENUMERAL_TYPE block.

    I resorted to hoisting the check along with a diagnostic tweak: we
    don't want to print "::::~E names destructor".

    gcc/cp/ChangeLog:

            PR c++/96462
            * name-lookup.c (lookup_using_decl): Hoist the destructor check.

    gcc/testsuite/ChangeLog:

            PR c++/96462
            * g++.dg/cpp2a/using-enum-8.C: New test.

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

* [Bug c++/96462] [10 Regression] ICE in  tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97
  2020-08-04 16:00 [Bug c++/96462] New: [10/11 Regression] ICE in tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97 haoxintu at gmail dot com
                   ` (6 preceding siblings ...)
  2021-02-05 16:07 ` cvs-commit at gcc dot gnu.org
@ 2021-02-05 16:08 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-05 16:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
            Summary|[10/11 Regression] ICE in   |[10 Regression] ICE in
                   |tree check: expected        |tree check: expected
                   |identifier_node, have       |identifier_node, have
                   |bit_not_expr in             |bit_not_expr in
                   |find_namespace_slot, at     |find_namespace_slot, at
                   |cp/name-lookup.c:97         |cp/name-lookup.c:97

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed in GCC 11.

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

end of thread, other threads:[~2021-02-05 16:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 16:00 [Bug c++/96462] New: [10/11 Regression] ICE in tree check: expected identifier_node, have bit_not_expr in find_namespace_slot, at cp/name-lookup.c:97 haoxintu at gmail dot com
2020-08-04 16:03 ` [Bug c++/96462] " mpolacek at gcc dot gnu.org
2020-08-04 16:09 ` haoxintu at gmail dot com
2020-10-12 12:40 ` rguenth at gcc dot gnu.org
2021-02-04  2:31 ` mpolacek at gcc dot gnu.org
2021-02-04  2:41 ` mpolacek at gcc dot gnu.org
2021-02-04  2:46 ` mpolacek at gcc dot gnu.org
2021-02-05 16:07 ` cvs-commit at gcc dot gnu.org
2021-02-05 16:08 ` [Bug c++/96462] [10 " mpolacek 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).