This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/84305] ICE inlining a VLA cast expression


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

--- Comment #2 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Author: rsandifo
Date: Tue Feb 13 10:28:54 2018
New Revision: 257620

URL: https://gcc.gnu.org/viewcvs?rev=257620&root=gcc&view=rev
Log:
Add a DECL_EXPR for VLA pointer casts (PR 84305)

This PR was about a case in which we ended up with a MULT_EXPR
that was shared between an ungimplified VLA type and a pointer
calculation.  The SSA names used in the pointer calculation were
later freed, but they were still there in the VLA, and caused an
ICE when remapping the types during inlinling.

The fix is to add a DECL_EXPR that forces the VLA type sizes to be
gimplified too, but the tricky part is deciding where.  As the comment
in grokdeclarator says, we can't just add it to the statement list,
since the size might only be conditionally evaluated.  It might also
end up being evaluated out of sequence.

The patch gets around that by putting the DECL_EXPR in a BIND_EXPR
and adding the BIND_EXPR to the list of things that need to be
evaluated for the declarator.

2018-02-13  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/c/
        PR c/84305
        * c-decl.c (grokdeclarator): Create an anonymous TYPE_DECL
        in PARM and TYPENAME contexts too, but attach it to a BIND_EXPR
        and include the BIND_EXPR in the list of things that need to be
        pre-evaluated.

gcc/testsuite/
        PR c/84305
        * gcc.c-torture/compile/pr84305.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr84305.c
Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/testsuite/ChangeLog

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]