public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106465] New: ICE for VLA in struct in parameter of nested function
@ 2022-07-28 15:10 muecker at gwdg dot de
  2022-07-28 16:08 ` [Bug c/106465] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: muecker at gwdg dot de @ 2022-07-28 15:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106465
           Summary: ICE for VLA in struct in parameter of nested function
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: muecker at gwdg dot de
  Target Milestone: ---

int f()
{
  void g(int m, struct { char p[m]; } b) { }
}


https://godbolt.org/z/r8n5s6ocv

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

* [Bug c/106465] ICE for VLA in struct in parameter of nested function
  2022-07-28 15:10 [Bug c/106465] New: ICE for VLA in struct in parameter of nested function muecker at gwdg dot de
@ 2022-07-28 16:08 ` pinskia at gcc dot gnu.org
  2022-07-29  7:15 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-28 16:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.1.0, 11.1.0, 12.1.0,
                   |                            |8.1.0, 9.1.0

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note the ICE changed between GCC 8 and GCC 9.

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

* [Bug c/106465] ICE for VLA in struct in parameter of nested function
  2022-07-28 15:10 [Bug c/106465] New: ICE for VLA in struct in parameter of nested function muecker at gwdg dot de
  2022-07-28 16:08 ` [Bug c/106465] " pinskia at gcc dot gnu.org
@ 2022-07-29  7:15 ` rguenth at gcc dot gnu.org
  2023-02-20 15:20 ` muecker at gwdg dot de
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-29  7:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-07-29
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  The ICE is the following

> ./cc1 -quiet t.c
t.c: In function 'f':
t.c:3:17: warning: anonymous struct declared inside parameter list will not be
visible outside of this definition or declaration
    3 |   void g(int m, struct { char p[m]; } b) { }
      |                 ^~~~~~
t.c:1:5: internal compiler error: m from g referenced in f
    1 | int f()
      |     ^
0x15818d9 convert_nonlocal_reference_op
        /home/rguenther/src/trunk/gcc/tree-nested.cc:1164

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

* [Bug c/106465] ICE for VLA in struct in parameter of nested function
  2022-07-28 15:10 [Bug c/106465] New: ICE for VLA in struct in parameter of nested function muecker at gwdg dot de
  2022-07-28 16:08 ` [Bug c/106465] " pinskia at gcc dot gnu.org
  2022-07-29  7:15 ` rguenth at gcc dot gnu.org
@ 2023-02-20 15:20 ` muecker at gwdg dot de
  2023-03-24 23:09 ` muecker at gwdg dot de
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: muecker at gwdg dot de @ 2023-02-20 15:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Martin Uecker <muecker at gwdg dot de> ---
Created attachment 54496
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54496&action=edit
patch for C FE


Here is a patch.

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

* [Bug c/106465] ICE for VLA in struct in parameter of nested function
  2022-07-28 15:10 [Bug c/106465] New: ICE for VLA in struct in parameter of nested function muecker at gwdg dot de
                   ` (2 preceding siblings ...)
  2023-02-20 15:20 ` muecker at gwdg dot de
@ 2023-03-24 23:09 ` muecker at gwdg dot de
  2023-05-18 13:00 ` muecker at gwdg dot de
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: muecker at gwdg dot de @ 2023-03-24 23:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Martin Uecker <muecker at gwdg dot de> ---
This version works with 4.1.2

https://godbolt.org/z/x4v6aTv87

int h(void)
{
    int g(int m, struct { char (*p)[m]; }* b) { return sizeof *b->p; }
    return g(5, 0);
}

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

* [Bug c/106465] ICE for VLA in struct in parameter of nested function
  2022-07-28 15:10 [Bug c/106465] New: ICE for VLA in struct in parameter of nested function muecker at gwdg dot de
                   ` (3 preceding siblings ...)
  2023-03-24 23:09 ` muecker at gwdg dot de
@ 2023-05-18 13:00 ` muecker at gwdg dot de
  2023-05-19 20:52 ` muecker at gwdg dot de
  2023-05-23 20:05 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: muecker at gwdg dot de @ 2023-05-18 13:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Martin Uecker <muecker at gwdg dot de> ---
PATCH: https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618911.html

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

* [Bug c/106465] ICE for VLA in struct in parameter of nested function
  2022-07-28 15:10 [Bug c/106465] New: ICE for VLA in struct in parameter of nested function muecker at gwdg dot de
                   ` (4 preceding siblings ...)
  2023-05-18 13:00 ` muecker at gwdg dot de
@ 2023-05-19 20:52 ` muecker at gwdg dot de
  2023-05-23 20:05 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: muecker at gwdg dot de @ 2023-05-19 20:52 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Uecker <muecker at gwdg dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #6 from Martin Uecker <muecker at gwdg dot de> ---

Was filed previously as PR70418

*** This bug has been marked as a duplicate of bug 70418 ***

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

* [Bug c/106465] ICE for VLA in struct in parameter of nested function
  2022-07-28 15:10 [Bug c/106465] New: ICE for VLA in struct in parameter of nested function muecker at gwdg dot de
                   ` (5 preceding siblings ...)
  2023-05-19 20:52 ` muecker at gwdg dot de
@ 2023-05-23 20:05 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-23 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Uecker <uecker@gcc.gnu.org>:

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

commit r14-1142-gf9b5be322358ee63798e02a9103b6bbe459e7aea
Author: Martin Uecker <uecker@tugraz.at>
Date:   Thu Apr 13 19:37:12 2023 +0200

    Fix ICEs related to VM types in C 1/2 [PR70418, PR107557, PR108423]

    Size expressions were sometimes lost and not gimplified correctly, leading
to
    ICEs and incorrect evaluation order.  Fix this by 1) not recursing into
    pointers when gimplifying parameters in the middle-end (the code is merged
with
    gimplify_type_sizes), which is incorrect because it might access variables
    declared later for incomplete structs, and 2) tracking size expressions for
    struct/union members correctly, 3) emitting code to evaluate size
expressions
    for missing cases (nested functions, empty declarations, and
structs/unions).

            PR c/70418
            PR c/106465
            PR c/107557
            PR c/108423

            gcc/c/
            * c-decl.cc (start_decl): Make sure size expression are
            evaluated only in correct context.
            (grokdeclarator): Size expression in fields may need a bind
            expression, make sure DECL_EXPR is always created.
            (grokfield, declspecs_add_type): Pass along size expressions.
            (finish_struct): Remove unneeded DECL_EXPR.
            (start_function): Evaluate size expressions for nested functions.
            * c-parser.cc (c_parser_struct_declarations,
            c_parser_struct_or_union_specifier): Pass along size expressions.
            (c_parser_declaration_or_fndef): Evaluate size expression.
            (c_parser_objc_at_property_declaration,
            c_parser_objc_class_instance_variables): Adapt.
            * c-tree.h (grokfield): Adapt declaration.

            gcc/testsuite/
            * gcc.dg/nested-vla-1.c: New test.
            * gcc.dg/nested-vla-2.c: New test.
            * gcc.dg/nested-vla-3.c: New test.
            * gcc.dg/pr70418.c: New test.
            * gcc.dg/pr106465.c: New test.
            * gcc.dg/pr107557-1.c: New test.
            * gcc.dg/pr107557-2.c: New test.
            * gcc.dg/pr108423-1.c: New test.
            * gcc.dg/pr108423-2.c: New test.
            * gcc.dg/pr108423-3.c: New test.
            * gcc.dg/pr108423-4.c: New test.
            * gcc.dg/pr108423-5.c: New test.
            * gcc.dg/pr108423-6.c: New test.
            * gcc.dg/typename-vla-2.c: New test.
            * gcc.dg/typename-vla-3.c: New test.
            * gcc.dg/typename-vla-4.c: New test.
            * gcc.misc-tests/gcov-pr85350.c: Adapt.

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

end of thread, other threads:[~2023-05-23 20:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-28 15:10 [Bug c/106465] New: ICE for VLA in struct in parameter of nested function muecker at gwdg dot de
2022-07-28 16:08 ` [Bug c/106465] " pinskia at gcc dot gnu.org
2022-07-29  7:15 ` rguenth at gcc dot gnu.org
2023-02-20 15:20 ` muecker at gwdg dot de
2023-03-24 23:09 ` muecker at gwdg dot de
2023-05-18 13:00 ` muecker at gwdg dot de
2023-05-19 20:52 ` muecker at gwdg dot de
2023-05-23 20:05 ` cvs-commit 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).