public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95192] New: [11 Regression] ICE: tree check: expected tree_list, have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996
@ 2020-05-18 19:57 asolokha at gmx dot com
  2020-05-18 20:03 ` [Bug c++/95192] " mpolacek at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: asolokha at gmx dot com @ 2020-05-18 19:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95192
           Summary: [11 Regression] ICE: tree check: expected tree_list,
                    have error_mark in handle_assume_aligned_attribute, at
                    c-family/c-attribs.c:2996
           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: asolokha at gmx dot com
  Target Milestone: ---

gcc-11.0.0-alpha20200517 snapshot (g:2b9a271b2d0ba340234a138b7f8289bd7dca2fc5)
ICEs when compiling the following testcase, extracted from
test/SemaCXX/builtin-assume-aligned-tmpl.cpp from the clang 10.0.0 test suite:

template<typename T> __attribute__((assume_aligned(sizeof(int(T()))))) T *f();
void test21() {
  void *p = f<void>()
}

% g++-11.0.0 -c iu1wkpbg.cpp
iu1wkpbg.cpp: In substitution of 'template<class T> T* f() [with T = void]':
iu1wkpbg.cpp:3:21:   required from here
iu1wkpbg.cpp:1:75: internal compiler error: tree check: expected tree_list,
have error_mark in handle_assume_aligned_attribute, at
c-family/c-attribs.c:2996
    1 | template<typename T> __attribute__((assume_aligned(sizeof(int(T())))))
T *f();
      |                                                                        
  ^
0x7c0c50 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/tree.c:9686
0x6af9db tree_check(tree_node*, char const*, int, char const*, tree_code)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/tree.h:3296
0x6af9db handle_assume_aligned_attribute
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/c-family/c-attribs.c:2996
0x6af9db handle_assume_aligned_attribute
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/c-family/c-attribs.c:2977
0xa96507 decl_attributes(tree_node**, tree_node*, int, tree_node*)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/attribs.c:714
0x9236f7 cplus_decl_attributes(tree_node**, tree_node*, int)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/decl2.c:1598
0xa178f4 tsubst_function_decl
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/pt.c:13929
0xa0196f tsubst_decl
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/pt.c:14182
0xa11b19 instantiate_template_1
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/pt.c:20678
0xa2137c instantiate_template(tree_node*, tree_node*, int)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/pt.c:20735
0xa2137c fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/pt.c:21179
0x876223 add_template_candidate_real
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/call.c:3415
0x876cf6 add_template_candidate
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/call.c:3500
0x876cf6 add_candidates
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/call.c:5866
0x8771e7 add_candidates
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/call.c:4522
0x8771e7 perform_overload_resolution
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/call.c:4530
0x87eea5 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/call.c:4604
0xa3d1b4 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/semantics.c:2675
0x9b3e51 cp_parser_postfix_expression
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/parser.c:7465
0x9958e9 cp_parser_binary_expression
       
/var/tmp/portage/sys-devel/gcc-11.0.0_alpha20200517/work/gcc-11-20200517/gcc/cp/parser.c:9559

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

* [Bug c++/95192] [11 Regression] ICE: tree check: expected tree_list,  have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996
  2020-05-18 19:57 [Bug c++/95192] New: [11 Regression] ICE: tree check: expected tree_list, have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996 asolokha at gmx dot com
@ 2020-05-18 20:03 ` mpolacek at gcc dot gnu.org
  2020-05-19  6:41 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-18 20:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-05-18
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.  Started with r11-423-gcda6396a1b6e6bba2a3b0847931567c3458f2184

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

* [Bug c++/95192] [11 Regression] ICE: tree check: expected tree_list,  have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996
  2020-05-18 19:57 [Bug c++/95192] New: [11 Regression] ICE: tree check: expected tree_list, have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996 asolokha at gmx dot com
  2020-05-18 20:03 ` [Bug c++/95192] " mpolacek at gcc dot gnu.org
@ 2020-05-19  6:41 ` rguenth at gcc dot gnu.org
  2020-10-16 11:45 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-19  6:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0

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

* [Bug c++/95192] [11 Regression] ICE: tree check: expected tree_list,  have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996
  2020-05-18 19:57 [Bug c++/95192] New: [11 Regression] ICE: tree check: expected tree_list, have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996 asolokha at gmx dot com
  2020-05-18 20:03 ` [Bug c++/95192] " mpolacek at gcc dot gnu.org
  2020-05-19  6:41 ` rguenth at gcc dot gnu.org
@ 2020-10-16 11:45 ` rguenth at gcc dot gnu.org
  2020-11-18 14:59 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-16 11:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1

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

* [Bug c++/95192] [11 Regression] ICE: tree check: expected tree_list,  have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996
  2020-05-18 19:57 [Bug c++/95192] New: [11 Regression] ICE: tree check: expected tree_list, have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996 asolokha at gmx dot com
                   ` (2 preceding siblings ...)
  2020-10-16 11:45 ` rguenth at gcc dot gnu.org
@ 2020-11-18 14:59 ` jakub at gcc dot gnu.org
  2020-12-04 14:17 ` marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-18 14:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
In cp/parser.c, we have code that avoids building attributes with
error_mark_node values (instead just use error_mark_node as the attributes).

So, I wonder if we shouldn't do that in tsubst_attributes too, like:
--- gcc/cp/pt.c.jj      2020-11-18 09:40:09.618663053 +0100
+++ gcc/cp/pt.c 2020-11-18 15:47:26.584181671 +0100
@@ -11502,6 +11502,8 @@ tsubst_attribute (tree t, tree *decl_p,
       tree chain
        = tsubst_expr (TREE_CHAIN (val), args, complain, in_decl,
                       /*integral_constant_expression_p=*/false);
+      if (chain == error_mark_node)
+       return error_mark_node;
       if (chain != TREE_CHAIN (val))
        val = tree_cons (NULL_TREE, TREE_VALUE (val), chain);
     }
@@ -11524,8 +11526,12 @@ tsubst_attribute (tree t, tree *decl_p,
       return list;
     }
   else
-    val = tsubst_expr (val, args, complain, in_decl,
-                      /*integral_constant_expression_p=*/false);
+    {
+      val = tsubst_expr (val, args, complain, in_decl,
+                        /*integral_constant_expression_p=*/false);
+      if (val == error_mark_node)
+       return val;
+    }

   if (val != TREE_VALUE (t))
     return build_tree_list (TREE_PURPOSE (t), val);

Except that we accept the testcase then rather than reject - the unification is
done with complain == 0...

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

* [Bug c++/95192] [11 Regression] ICE: tree check: expected tree_list,  have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996
  2020-05-18 19:57 [Bug c++/95192] New: [11 Regression] ICE: tree check: expected tree_list, have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996 asolokha at gmx dot com
                   ` (3 preceding siblings ...)
  2020-11-18 14:59 ` jakub at gcc dot gnu.org
@ 2020-12-04 14:17 ` marxin at gcc dot gnu.org
  2020-12-04 14:20 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-12-04 14:17 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #2)
> In cp/parser.c, we have code that avoids building attributes with
> error_mark_node values (instead just use error_mark_node as the attributes).
> 
> So, I wonder if we shouldn't do that in tsubst_attributes too, like:
> --- gcc/cp/pt.c.jj	2020-11-18 09:40:09.618663053 +0100
> +++ gcc/cp/pt.c	2020-11-18 15:47:26.584181671 +0100
> @@ -11502,6 +11502,8 @@ tsubst_attribute (tree t, tree *decl_p,
>        tree chain
>  	= tsubst_expr (TREE_CHAIN (val), args, complain, in_decl,
>  		       /*integral_constant_expression_p=*/false);
> +      if (chain == error_mark_node)
> +	return error_mark_node;
>        if (chain != TREE_CHAIN (val))
>  	val = tree_cons (NULL_TREE, TREE_VALUE (val), chain);
>      }
> @@ -11524,8 +11526,12 @@ tsubst_attribute (tree t, tree *decl_p,
>        return list;
>      }
>    else
> -    val = tsubst_expr (val, args, complain, in_decl,
> -		       /*integral_constant_expression_p=*/false);
> +    {
> +      val = tsubst_expr (val, args, complain, in_decl,
> +			 /*integral_constant_expression_p=*/false);
> +      if (val == error_mark_node)
> +	return val;
> +    }
>  
>    if (val != TREE_VALUE (t))
>      return build_tree_list (TREE_PURPOSE (t), val);
> 
> Except that we accept the testcase then rather than reject - the unification
> is done with complain == 0...

Are you planning Jakub to send the patch candidate to the mailing list?

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

* [Bug c++/95192] [11 Regression] ICE: tree check: expected tree_list,  have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996
  2020-05-18 19:57 [Bug c++/95192] New: [11 Regression] ICE: tree check: expected tree_list, have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996 asolokha at gmx dot com
                   ` (4 preceding siblings ...)
  2020-12-04 14:17 ` marxin at gcc dot gnu.org
@ 2020-12-04 14:20 ` jakub at gcc dot gnu.org
  2021-02-01 21:46 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-12-04 14:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
No, because it isn't sufficient, I believe we need to reject it rather than
accept it.

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

* [Bug c++/95192] [11 Regression] ICE: tree check: expected tree_list,  have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996
  2020-05-18 19:57 [Bug c++/95192] New: [11 Regression] ICE: tree check: expected tree_list, have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996 asolokha at gmx dot com
                   ` (5 preceding siblings ...)
  2020-12-04 14:20 ` jakub at gcc dot gnu.org
@ 2021-02-01 21:46 ` jason at gcc dot gnu.org
  2021-02-04  2:38 ` cvs-commit at gcc dot gnu.org
  2021-02-04  2:40 ` jason at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2021-02-01 21:46 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

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

* [Bug c++/95192] [11 Regression] ICE: tree check: expected tree_list,  have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996
  2020-05-18 19:57 [Bug c++/95192] New: [11 Regression] ICE: tree check: expected tree_list, have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996 asolokha at gmx dot com
                   ` (6 preceding siblings ...)
  2021-02-01 21:46 ` jason at gcc dot gnu.org
@ 2021-02-04  2:38 ` cvs-commit at gcc dot gnu.org
  2021-02-04  2:40 ` jason at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-04  2:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:7b258ac7afaaf7d8157df10ea35c6002d935d7d0

commit r11-7095-g7b258ac7afaaf7d8157df10ea35c6002d935d7d0
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Feb 1 17:24:05 2021 -0500

    c++: subst failure in attribute argument [PR95192]

    Another SFINAE issue: we weren't propagating substitution failure in
    attributes back up.  And tsubst_function_decl needs to check substitution
    before register_specialization.  I thought about moving the other error
    returns up as well, but they aren't SFINAE cases, so they can stay where
    they are.

    This change caused pr84630.C to stop giving an error; this was because
    partial instantiation of the lambda failed silently, and before the change
    that meant error_mark_node passed to decl_attributes, which complained
about
    there being an argument at all.  With the change the partial instantiation
    fails, but no error was ever given, because push_template_decl silently
    failed if current_template_parms wasn't set.  So let's set c_t_p
    appropriately.  lambda-uneval13.C is a valid testcase to exercise this.

    gcc/cp/ChangeLog:

            PR c++/95192
            * pt.c (tsubst_attribute): Handle error.
            (apply_late_template_attributes): Return false on error.
            (tsubst_function_decl): Check its return value.
            (tsubst_decl): Likewise.
            (push_template_decl): Assert current_template_parms.
            (tsubst_template_decl): Set current_template_parms.

    gcc/testsuite/ChangeLog:

            PR c++/95192
            * g++.dg/cpp0x/pr84630.C: Call b().
            * g++.dg/cpp2a/lambda-uneval13.C: New test.
            * g++.dg/ext/attr-expr1.C: New test.

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

* [Bug c++/95192] [11 Regression] ICE: tree check: expected tree_list,  have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996
  2020-05-18 19:57 [Bug c++/95192] New: [11 Regression] ICE: tree check: expected tree_list, have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996 asolokha at gmx dot com
                   ` (7 preceding siblings ...)
  2021-02-04  2:38 ` cvs-commit at gcc dot gnu.org
@ 2021-02-04  2:40 ` jason at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2021-02-04  2:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-02-04  2:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18 19:57 [Bug c++/95192] New: [11 Regression] ICE: tree check: expected tree_list, have error_mark in handle_assume_aligned_attribute, at c-family/c-attribs.c:2996 asolokha at gmx dot com
2020-05-18 20:03 ` [Bug c++/95192] " mpolacek at gcc dot gnu.org
2020-05-19  6:41 ` rguenth at gcc dot gnu.org
2020-10-16 11:45 ` rguenth at gcc dot gnu.org
2020-11-18 14:59 ` jakub at gcc dot gnu.org
2020-12-04 14:17 ` marxin at gcc dot gnu.org
2020-12-04 14:20 ` jakub at gcc dot gnu.org
2021-02-01 21:46 ` jason at gcc dot gnu.org
2021-02-04  2:38 ` cvs-commit at gcc dot gnu.org
2021-02-04  2:40 ` jason 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).