Message ID | AM6PR10MB25661D8C5F20E483BB473CDEE4B30@AM6PR10MB2566.EURPRD10.PROD.OUTLOOK.COM |
---|---|
State | New |
Headers | show |
Series | Fix PR fortran/91716 | expand |
On Fri, Sep 13, 2019 at 1:07 PM Bernd Edlinger <bernd.edlinger@hotmail.de> wrote: > > Hi, > > this fixes a test case where a short string constant is put in a larger memory object. > > The consistency check in varasm.c is failed because both types should agree. > > Since the failed assertion is just a gcc_checking_assert I think a back-port of this fix > to the gcc-9 branch will not be necessary. > > > Bootstrapped and reg-tested on x86_64-pc-linux-gnu. > Is it OK for trunk? > > > Thanks > Bernd. Ok.
On 9/13/19 12:16 PM, Janne Blomqvist wrote: > On Fri, Sep 13, 2019 at 1:07 PM Bernd Edlinger > <bernd.edlinger@hotmail.de> wrote: >> >> Hi, >> >> this fixes a test case where a short string constant is put in a larger memory object. >> >> The consistency check in varasm.c is failed because both types should agree. >> >> Since the failed assertion is just a gcc_checking_assert I think a back-port of this fix >> to the gcc-9 branch will not be necessary. >> >> >> Bootstrapped and reg-tested on x86_64-pc-linux-gnu. >> Is it OK for trunk? >> >> >> Thanks >> Bernd. > > Ok. > Well, I have mistakenly assumed that this triggers only a "checking" assert, but it turned out that is not the case, as written in last comment in the BZ, immediately after that gcc_checking_assert, there is a gcc_assert, and also an ICE in the gcc-9 branch. The same patch fixes also the second problem, and survives reg-bootstrap and testing on x86_64-pc-linux-gnu as expected. So I would like to ask at this time, if it is also OK for gcc-9 ? Thanks Bernd.
On Tue, Oct 01, 2019 at 07:58:37PM +0000, Bernd Edlinger wrote: > On 9/13/19 12:16 PM, Janne Blomqvist wrote: > > On Fri, Sep 13, 2019 at 1:07 PM Bernd Edlinger > > <bernd.edlinger@hotmail.de> wrote: > >> > >> Hi, > >> > >> this fixes a test case where a short string constant is put in a larger memory object. > >> > >> The consistency check in varasm.c is failed because both types should agree. > >> > >> Since the failed assertion is just a gcc_checking_assert I think a back-port of this fix > >> to the gcc-9 branch will not be necessary. > >> > >> Bootstrapped and reg-tested on x86_64-pc-linux-gnu. > >> Is it OK for trunk? > >> > >> Thanks > >> Bernd. > > > > Ok. > > > > Well, I have mistakenly assumed that this triggers only a "checking" assert, > but it turned out that is not the case, as written in last comment in the BZ, > immediately after that gcc_checking_assert, there is a gcc_assert, and also > an ICE in the gcc-9 branch. The same patch fixes also the second problem, > and survives reg-bootstrap and testing on x86_64-pc-linux-gnu as expected. > > > So I would like to ask at this time, if it is also OK for gcc-9 ? > > If you're backporting a patch from trunk to 9-branch, then I think it is ok to commit.
2019-09-13 Bernd Edlinger <bernd.edlinger@hotmail.de> PR fortran/91716 * trans-array.c (gfc_conv_array_initializer): Always assign the array type of the field to the string constant. testsuite: 2019-09-13 Bernd Edlinger <bernd.edlinger@hotmail.de> PR fortran/91716 * gfortran.dg/pr91716.f90: New test. Index: gcc/fortran/trans-array.c =================================================================== --- gcc/fortran/trans-array.c (revision 275685) +++ gcc/fortran/trans-array.c (working copy) @@ -6108,9 +6108,12 @@ gfc_conv_array_initializer (tree type, gfc_expr * tree atype = type; while (TREE_CODE (TREE_TYPE (atype)) == ARRAY_TYPE) atype = TREE_TYPE (atype); - if (TREE_CODE (TREE_TYPE (atype)) == INTEGER_TYPE - && tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (se.expr))) - > tree_to_uhwi (TYPE_SIZE_UNIT (atype))) + gcc_checking_assert (TREE_CODE (TREE_TYPE (atype)) + == INTEGER_TYPE); + gcc_checking_assert (TREE_TYPE (TREE_TYPE (se.expr)) + == TREE_TYPE (atype)); + if (tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (se.expr))) + > tree_to_uhwi (TYPE_SIZE_UNIT (atype))) { unsigned HOST_WIDE_INT size = tree_to_uhwi (TYPE_SIZE_UNIT (atype)); @@ -6117,8 +6120,8 @@ gfc_conv_array_initializer (tree type, gfc_expr * const char *p = TREE_STRING_POINTER (se.expr); se.expr = build_string (size, p); - TREE_TYPE (se.expr) = atype; } + TREE_TYPE (se.expr) = atype; } break; Index: gcc/testsuite/gfortran.dg/pr91716.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr91716.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/pr91716.f90 (working copy) @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/91716 +! Code contributed by Gerhard Steinmetz +module m + type t + character :: c(2) = [character(-1) :: 'a', 'b'] + end type +end