public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106560] New: ICE after conflicting types of redeclaration
@ 2022-08-08 15:46 pinskia at gcc dot gnu.org
  2022-08-08 15:47 ` [Bug c/106560] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-08 15:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106560
           Summary: ICE after conflicting types of redeclaration
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: error-recovery, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

```
void **a;
void b() { void **c = a; }
a;
```

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

* [Bug c/106560] ICE after conflicting types of redeclaration
  2022-08-08 15:46 [Bug c/106560] New: ICE after conflicting types of redeclaration pinskia at gcc dot gnu.org
@ 2022-08-08 15:47 ` pinskia at gcc dot gnu.org
  2022-08-08 15:48 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-08 15:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
<source>:4:1: warning: data definition has no type or storage class
    4 | a;
      | ^
<source>:4:1: warning: type defaults to 'int' in declaration of 'a'
[-Wimplicit-int]
<source>:4:1: error: conflicting types for 'a'; have 'int'
<source>:2:8: note: previous declaration of 'a' with type 'void **'
    2 | void **a;
      |        ^
<source>: In function 'b':
<source>:3:19: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in useless_type_conversion_p, at gimple-expr.cc:87
    3 | void b() { void **c = a; }
      |                   ^
0x200570e internal_error(char const*, ...)
        ???:0
0x84a7cf tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ???:0
0xd1be13 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xd1f84a gimplify_stmt(tree_node**, gimple**)
        ???:0
0xd1bf27 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xd1f84a gimplify_stmt(tree_node**, gimple**)
        ???:0
0xd1c7fe gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        ???:0
0xd1f84a gimplify_stmt(tree_node**, gimple**)
        ???:0
0xd20ed3 gimplify_body(tree_node*, bool)
        ???:0
0xd2131f gimplify_function_tree(tree_node*)
        ???:0
0xb5a2d7 cgraph_node::analyze()
        ???:0
0xb5dd91 symbol_table::finalize_compilation_unit()
        ???:0
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

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

* [Bug c/106560] ICE after conflicting types of redeclaration
  2022-08-08 15:46 [Bug c/106560] New: ICE after conflicting types of redeclaration pinskia at gcc dot gnu.org
  2022-08-08 15:47 ` [Bug c/106560] " pinskia at gcc dot gnu.org
@ 2022-08-08 15:48 ` pinskia at gcc dot gnu.org
  2022-08-08 15:56 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-08 15:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The full backtrace:
t.c:4:1: warning: data definition has no type or storage class
    4 | a;
      | ^
t.c:4:1: warning: type defaults to ‘int’ in declaration of ‘a’ [-Wimplicit-int]
t.c:4:1: error: conflicting types for ‘a’; have ‘int’
t.c:2:8: note: previous declaration of ‘a’ with type ‘void **’
    2 | void **a;
      |        ^

Analyzing compilation unit
t.c: In function ‘b’:
t.c:3:19: internal compiler error: tree check: expected class ‘type’, have
‘exceptional’ (error_mark) in useless_type_conversion_p, at gimple-expr.cc:87
    3 | void b() { void **c = a; }
      |                   ^
0x182bb35 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/tree.cc:8867
0xac8be5 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/tree.h:3631
0xf5f04d useless_type_conversion_p(tree_node*, tree_node*)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimple-expr.cc:87
0xfcd0e4 gimplify_modify_expr
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:6040
0xffb8c1 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:15209
0xfd172d gimplify_stmt(tree_node**, gimple**)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:7156
0xfbb246 gimplify_and_add(tree_node*, gimple**)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:496
0xfbfcba gimplify_decl_expr
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:1942
0xffc5fb gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:15406
0xfd172d gimplify_stmt(tree_node**, gimple**)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:7156
0xfbdd58 gimplify_bind_expr
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:1434
0xffc61c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:15410
0xfd172d gimplify_stmt(tree_node**, gimple**)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:7156
0x10003ce gimplify_body(tree_node*, bool)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:16466
0x1000ca4 gimplify_function_tree(tree_node*)
        /home/apinski/src/upstream-gcc-git/gcc/gcc/gimplify.cc:16665
0xd4e447 cgraph_node::analyze()
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cgraphunit.cc:676
0xd504e8 analyze_functions
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cgraphunit.cc:1240
0xd536b5 symbol_table::finalize_compilation_unit()
        /home/apinski/src/upstream-gcc-git/gcc/gcc/cgraphunit.cc:2500
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.

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

* [Bug c/106560] ICE after conflicting types of redeclaration
  2022-08-08 15:46 [Bug c/106560] New: ICE after conflicting types of redeclaration pinskia at gcc dot gnu.org
  2022-08-08 15:47 ` [Bug c/106560] " pinskia at gcc dot gnu.org
  2022-08-08 15:48 ` pinskia at gcc dot gnu.org
@ 2022-08-08 15:56 ` pinskia at gcc dot gnu.org
  2022-08-08 16:00 ` k.even-mendoza at imperial dot ac.uk
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-08 15:56 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-08-08
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is the simple fix, I will submit it this weekend.
[apinski@xeond2 gcc]$ git diff
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index f0fbdb48012..d9ada8e0f9e 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -6012,6 +6012,11 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p,
gimple_seq *post_p,
   gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR
              || TREE_CODE (*expr_p) == INIT_EXPR);

+  if (TREE_TYPE (*from_p) == error_mark_node)
+    return GS_ERROR;
+  if (TREE_TYPE (*to_p) == error_mark_node)
+    return GS_ERROR;
+
   /* Trying to simplify a clobber using normal logic doesn't work,
      so handle it here.  */
   if (TREE_CLOBBER_P (*from_p))

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

* [Bug c/106560] ICE after conflicting types of redeclaration
  2022-08-08 15:46 [Bug c/106560] New: ICE after conflicting types of redeclaration pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-08-08 15:56 ` pinskia at gcc dot gnu.org
@ 2022-08-08 16:00 ` k.even-mendoza at imperial dot ac.uk
  2022-08-08 16:02 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: k.even-mendoza at imperial dot ac.uk @ 2022-08-08 16:00 UTC (permalink / raw)
  To: gcc-bugs

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

Karine EM <k.even-mendoza at imperial dot ac.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |k.even-mendoza at imperial dot ac.
                   |                            |uk

--- Comment #4 from Karine EM <k.even-mendoza at imperial dot ac.uk> ---
Thanks! If it helps with the fix, here are two more examples of this crash:

=======
void **a, **b;
c(){b = a;}  
a =

======
void **a;
void b() {
  void **c;                        for
    c = a
}
a;
=====

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

* [Bug c/106560] ICE after conflicting types of redeclaration
  2022-08-08 15:46 [Bug c/106560] New: ICE after conflicting types of redeclaration pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-08-08 16:00 ` k.even-mendoza at imperial dot ac.uk
@ 2022-08-08 16:02 ` pinskia at gcc dot gnu.org
  2022-08-09  7:38 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-08 16:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Karine EM from comment #4)
> Thanks! If it helps with the fix, here are two more examples of this crash:

The fix I have fixes both of these too.
I will add all three to the testsuite when I submit the patch.

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

* [Bug c/106560] ICE after conflicting types of redeclaration
  2022-08-08 15:46 [Bug c/106560] New: ICE after conflicting types of redeclaration pinskia at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-08-08 16:02 ` pinskia at gcc dot gnu.org
@ 2022-08-09  7:38 ` rguenth at gcc dot gnu.org
  2022-08-09 17:54 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-08-09  7:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> Here is the simple fix, I will submit it this weekend.
> [apinski@xeond2 gcc]$ git diff
> diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
> index f0fbdb48012..d9ada8e0f9e 100644
> --- a/gcc/gimplify.cc
> +++ b/gcc/gimplify.cc
> @@ -6012,6 +6012,11 @@ gimplify_modify_expr (tree *expr_p, gimple_seq
> *pre_p, gimple_seq *post_p,
>    gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR
>               || TREE_CODE (*expr_p) == INIT_EXPR);
> 
> +  if (TREE_TYPE (*from_p) == error_mark_node)

  if (error_operand_p (*from_p))


> +    return GS_ERROR;
> +  if (TREE_TYPE (*to_p) == error_mark_node)
> +    return GS_ERROR;
> +
>    /* Trying to simplify a clobber using normal logic doesn't work,
>       so handle it here.  */
>    if (TREE_CLOBBER_P (*from_p))

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

* [Bug c/106560] ICE after conflicting types of redeclaration
  2022-08-08 15:46 [Bug c/106560] New: ICE after conflicting types of redeclaration pinskia at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-08-09  7:38 ` rguenth at gcc dot gnu.org
@ 2022-08-09 17:54 ` pinskia at gcc dot gnu.org
  2022-11-19 20:53 ` [Bug c/106560] [12/13 Regression] " pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-09 17:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #6)
> (In reply to Andrew Pinski from comment #3)
> > Here is the simple fix, I will submit it this weekend.
> > [apinski@xeond2 gcc]$ git diff
> > diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
> > index f0fbdb48012..d9ada8e0f9e 100644
> > --- a/gcc/gimplify.cc
> > +++ b/gcc/gimplify.cc
> > @@ -6012,6 +6012,11 @@ gimplify_modify_expr (tree *expr_p, gimple_seq
> > *pre_p, gimple_seq *post_p,
> >    gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR
> >               || TREE_CODE (*expr_p) == INIT_EXPR);
> > 
> > +  if (TREE_TYPE (*from_p) == error_mark_node)
> 
>   if (error_operand_p (*from_p))

Oh Ok, There was a few places which check directly against error_mark_node.
gimplify_decl_expr and gimplify_save_expr for example. I will submit a patch to
fix those too.

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

* [Bug c/106560] [12/13 Regression] ICE after conflicting types of redeclaration
  2022-08-08 15:46 [Bug c/106560] New: ICE after conflicting types of redeclaration pinskia at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-08-09 17:54 ` pinskia at gcc dot gnu.org
@ 2022-11-19 20:53 ` pinskia at gcc dot gnu.org
  2022-11-21  7:47 ` cvs-commit at gcc dot gnu.org
  2022-11-21  7:48 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-19 20:53 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.3
            Summary|ICE after conflicting types |[12/13 Regression] ICE
                   |of redeclaration            |after conflicting types of
                   |                            |redeclaration
           Severity|normal                      |trivial

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I am 99% sure this started after r12-3278-g823685221de986af. 
I am testing the fix right now (the one to use error_operand_p) and will be
posting it soon.

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

* [Bug c/106560] [12/13 Regression] ICE after conflicting types of redeclaration
  2022-08-08 15:46 [Bug c/106560] New: ICE after conflicting types of redeclaration pinskia at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-11-19 20:53 ` [Bug c/106560] [12/13 Regression] " pinskia at gcc dot gnu.org
@ 2022-11-21  7:47 ` cvs-commit at gcc dot gnu.org
  2022-11-21  7:48 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-21  7:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

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

commit r13-4181-gb03ad138a61f64d8a77876d6864aad5103fff498
Author: Andrew Pinski <apinski@marvell.com>
Date:   Sat Nov 19 12:48:27 2022 -0800

    Fix PR 106560: Another ICE after conflicting types of redeclaration

    This another one of these ICE after error issues with the
    gimplifier and a fallout from r12-3278-g823685221de986af.
    The problem here is gimplify_modify_expr does not
    check if either from or to was an error operand.
    This adds the check and fixes the ICE.

    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

    gcc/ChangeLog:

            * gimplify.cc (gimplify_modify_expr): If
            either *from_p or *to_p were error_operand
            return early.

    gcc/testsuite/ChangeLog:

            * gcc.dg/redecl-23.c: New test.
            * gcc.dg/redecl-24.c: New test.
            * gcc.dg/redecl-25.c: New test.

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

* [Bug c/106560] [12/13 Regression] ICE after conflicting types of redeclaration
  2022-08-08 15:46 [Bug c/106560] New: ICE after conflicting types of redeclaration pinskia at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2022-11-21  7:47 ` cvs-commit at gcc dot gnu.org
@ 2022-11-21  7:48 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-21  7:48 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|12.3                        |13.0
             Status|ASSIGNED                    |RESOLVED

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-11-21  7:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-08 15:46 [Bug c/106560] New: ICE after conflicting types of redeclaration pinskia at gcc dot gnu.org
2022-08-08 15:47 ` [Bug c/106560] " pinskia at gcc dot gnu.org
2022-08-08 15:48 ` pinskia at gcc dot gnu.org
2022-08-08 15:56 ` pinskia at gcc dot gnu.org
2022-08-08 16:00 ` k.even-mendoza at imperial dot ac.uk
2022-08-08 16:02 ` pinskia at gcc dot gnu.org
2022-08-09  7:38 ` rguenth at gcc dot gnu.org
2022-08-09 17:54 ` pinskia at gcc dot gnu.org
2022-11-19 20:53 ` [Bug c/106560] [12/13 Regression] " pinskia at gcc dot gnu.org
2022-11-21  7:47 ` cvs-commit at gcc dot gnu.org
2022-11-21  7:48 ` pinskia 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).