public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95728] New: [11 Regression] tree check: expected tree_list,  have error_mark in tsubst_copy_and_build, at cp/pt.c:19594
@ 2020-06-17 19:41 redi at gcc dot gnu.org
  2020-06-17 19:41 ` [Bug c++/95728] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2020-06-17 19:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95728
           Summary: [11 Regression] tree check: expected tree_list, have
                    error_mark in tsubst_copy_and_build, at cp/pt.c:19594
           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: redi at gcc dot gnu.org
                CC: jason at gcc dot gnu.org
  Target Milestone: ---

The code below is invalid (attempting to cast const T* to void*) but dies with
an ICE since r11-423:

    PR c++/93286 - ICE with __is_constructible and variadic template.

    My GCC 10 patch for 93286 fixed the missing piece in tsubst's handling of
    lists vs. that in tsubst_copy_and_build, but it would be better to share
the
    code between them.

template<typename T>
  void
  construct(T* p)
  { ::new(static_cast<void*>(p)) T; }

template<typename T>
void
f(const T* t)
{
  construct(t);
}

int main()
{
  int i[1];
  f(i);
}


ice.cc: In instantiation of 'void construct(T*) [with T = const int]':
ice.cc:10:12:   required from 'void f(const T*) [with T = int]'
ice.cc:16:6:   required from here
ice.cc:4:11: error: invalid 'static_cast' from type 'const int*' to type
'void*'
    4 |   { ::new(static_cast<void*>(p)) T; }
      |           ^~~~~~~~~~~~~~~~~~~~~
ice.cc:4:5: internal compiler error: tree check: expected tree_list, have
error_mark in tsubst_copy_and_build, at cp/pt.c:19640
    4 |   { ::new(static_cast<void*>(p)) T; }
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x81ac46 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        /home/jwakely/src/gcc/gcc/gcc/tree.c:9685
0x67d317 tree_check(tree_node*, char const*, int, char const*, tree_code)
        /home/jwakely/src/gcc/gcc/gcc/tree.h:3301
0x67d317 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:19640
0xa91287 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:18772
0xa93ab7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:17879
0xa92db1 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:18173
0xa90ba1 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:17834
0xa90ba1 instantiate_decl(tree_node*, bool, bool)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:25653
0xac281b instantiate_pending_templates(int)
        /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:25769
0x9cb4e0 c_parse_final_cleanups()
        /home/jwakely/src/gcc/gcc/gcc/cp/decl2.c:4899
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++/95728] [11 Regression] tree check: expected tree_list, have error_mark in tsubst_copy_and_build, at cp/pt.c:19594
  2020-06-17 19:41 [Bug c++/95728] New: [11 Regression] tree check: expected tree_list, have error_mark in tsubst_copy_and_build, at cp/pt.c:19594 redi at gcc dot gnu.org
@ 2020-06-17 19:41 ` redi at gcc dot gnu.org
  2020-06-17 23:16 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2020-06-17 19:41 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-06-17
     Ever confirmed|0                           |1
      Known to fail|                            |11.0
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |10.1.0

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

* [Bug c++/95728] [11 Regression] tree check: expected tree_list, have error_mark in tsubst_copy_and_build, at cp/pt.c:19594
  2020-06-17 19:41 [Bug c++/95728] New: [11 Regression] tree check: expected tree_list, have error_mark in tsubst_copy_and_build, at cp/pt.c:19594 redi at gcc dot gnu.org
  2020-06-17 19:41 ` [Bug c++/95728] " redi at gcc dot gnu.org
@ 2020-06-17 23:16 ` mpolacek at gcc dot gnu.org
  2020-06-17 23:20 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-17 23:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |11.0

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Since the introduction of tsubst_tree_list we now return a naked
error_mark_node rather than an error_mark_node wrapped in a TREE_LIST.  So
tsubst_copy_and_build/NEW_EXPR ICEs:

19654         tree placement = RECUR (TREE_OPERAND (t, 0)); // now a naked
error_mark_node
...
19668             for (; placement != NULL_TREE; placement = TREE_CHAIN
(placement)) // crash

A simple

--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19633,6 +19660,8 @@ tsubst_copy_and_build (tree t,

    if (placement == NULL_TREE)
      placement_vec = NULL;
+   else if (placement == error_mark_node)
+     RETURN (error_mark_node);
    else
      {
        placement_vec = make_tree_vector ();

should fix this.

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

* [Bug c++/95728] [11 Regression] tree check: expected tree_list, have error_mark in tsubst_copy_and_build, at cp/pt.c:19594
  2020-06-17 19:41 [Bug c++/95728] New: [11 Regression] tree check: expected tree_list, have error_mark in tsubst_copy_and_build, at cp/pt.c:19594 redi at gcc dot gnu.org
  2020-06-17 19:41 ` [Bug c++/95728] " redi at gcc dot gnu.org
  2020-06-17 23:16 ` mpolacek at gcc dot gnu.org
@ 2020-06-17 23:20 ` mpolacek at gcc dot gnu.org
  2020-06-18 12:33 ` cvs-commit at gcc dot gnu.org
  2020-06-18 12:35 ` mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-17 23:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
...which also generates a better diagnostic than gcc 10 & older.

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

* [Bug c++/95728] [11 Regression] tree check: expected tree_list, have error_mark in tsubst_copy_and_build, at cp/pt.c:19594
  2020-06-17 19:41 [Bug c++/95728] New: [11 Regression] tree check: expected tree_list, have error_mark in tsubst_copy_and_build, at cp/pt.c:19594 redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-06-17 23:20 ` mpolacek at gcc dot gnu.org
@ 2020-06-18 12:33 ` cvs-commit at gcc dot gnu.org
  2020-06-18 12:35 ` mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-18 12:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 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:81caacc273399c91ae3182021ad87bc2ba786039

commit r11-1507-g81caacc273399c91ae3182021ad87bc2ba786039
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Jun 17 19:23:10 2020 -0400

    c++: Fix tsubst ICE with invalid static_cast [PR95728]

    Since r11-423 tsubst_copy_and_build/TREE_LIST uses tsubst_tree_list
    instead of open coding it.  While the latter could return an error
    node wrapped in a TREE_LIST, the former can return a naked error node.

    That broke in tsubst_copy_and_build/NEW_EXPR:
      tree placement = RECUR (TREE_OPERAND (t, 0));
      // placement is now error_mark_node, so...
      for (; placement != NULL_TREE; placement = TREE_CHAIN (placement))
      // ... this crashes

    If we just return, we avoid the ICE and improve the diagnostic a bit.

    gcc/cp/ChangeLog:

            PR c++/95728
            * pt.c (tsubst_copy_and_build) <case NEW_EXPR>: Return
error_mark_node
            if placement is erroneous.

    gcc/testsuite/ChangeLog:

            PR c++/95728
            * g++.dg/template/cast6.C: New test.

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

* [Bug c++/95728] [11 Regression] tree check: expected tree_list, have error_mark in tsubst_copy_and_build, at cp/pt.c:19594
  2020-06-17 19:41 [Bug c++/95728] New: [11 Regression] tree check: expected tree_list, have error_mark in tsubst_copy_and_build, at cp/pt.c:19594 redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-06-18 12:33 ` cvs-commit at gcc dot gnu.org
@ 2020-06-18 12:35 ` mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-18 12:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2020-06-18 12:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17 19:41 [Bug c++/95728] New: [11 Regression] tree check: expected tree_list, have error_mark in tsubst_copy_and_build, at cp/pt.c:19594 redi at gcc dot gnu.org
2020-06-17 19:41 ` [Bug c++/95728] " redi at gcc dot gnu.org
2020-06-17 23:16 ` mpolacek at gcc dot gnu.org
2020-06-17 23:20 ` mpolacek at gcc dot gnu.org
2020-06-18 12:33 ` cvs-commit at gcc dot gnu.org
2020-06-18 12:35 ` 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).