Bug 83999 - [8/9 Regression] ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:10233
Summary: [8/9 Regression] ICE in gfc_trans_assignment_1, at fortran/trans-expr.c:10233
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 8.0
: P4 normal
Target Milestone: 8.3
Assignee: Paul Thomas
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2018-01-23 17:49 UTC by G. Steinmetz
Modified: 2018-10-08 14:22 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-01-24 00:00:00


Attachments
submit2.diff (8.10 KB, text/plain)
2018-01-24 20:27 UTC, paul.richard.thomas@gmail.com
Details
Patch for the PR (345 bytes, patch)
2018-10-06 12:57 UTC, Paul Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2018-01-23 17:49:46 UTC
Changed between 20171112 and 20171119 :


$ cat z1.f90
program p
   type t
      integer :: a
   end type
   type(t) :: x(3)
   x = f()
   print *, x
contains
   elemental function f() result(z)
      class(t), pointer :: z(:)
   end
end


$ gfortran-8-20171112 -c z1.f90
$
$ gfortran-8-20180121 -c z1.f90
z1.f90:6:0:

    x = f()

internal compiler error: in gfc_trans_assignment_1, at fortran/trans-expr.c:10233
0x784622 gfc_trans_assignment_1
        ../../gcc/fortran/trans-expr.c:10232
0x748027 trans_code
        ../../gcc/fortran/trans.c:1828
0x76ef29 gfc_generate_function_code(gfc_namespace*)
        ../../gcc/fortran/trans-decl.c:6451
0x6fecd0 translate_all_program_units
        ../../gcc/fortran/parse.c:6103
0x6fecd0 gfc_parse_file()
        ../../gcc/fortran/parse.c:6306
0x74520f gfc_be_parse_file
        ../../gcc/fortran/f95-lang.c:204
Comment 1 G. Steinmetz 2018-01-23 17:50:22 UTC
Please note that a result with "type" instead of "class" gives :


$ cat z2.f90
program p
   type t
      integer :: a
   end type
   type(t) :: x(3)
   x = f()
   print *, x
contains
   elemental function f() result(z)
      type(t), pointer :: z(:)
   end
end


$ gfortran-8-20171112 -c z2.f90
z2.f90:9:3:

    elemental function f() result(z)
   1
Error: ELEMENTAL function 'f' at (1) must have a scalar result


$ gfortran-8-20180121 -c z2.f90
z2.f90:9:3:

    elemental function f() result(z)
   1
Error: ELEMENTAL function 'f' at (1) must have a scalar result
Comment 2 Jakub Jelinek 2018-01-24 09:11:51 UTC
Started with r254936.
Comment 3 paul.richard.thomas@gmail.com 2018-01-24 20:27:26 UTC
Created attachment 43234 [details]
submit2.diff

Hi Jakub,

I have made the changes to the types of the dtype elements that you
suggested. It led to a cast being needed in
trans-intrinsic.c(gfc_conv_intrinsic_rank) but, apart from that, the
changes were straightforward. Please find the updated patch attached.

OK for trunk?

Once I have committed this patch, I promise that I will stick to
regressions and bug fixes through to release :-)

Paul


On 24 January 2018 at 09:11, jakub at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83999
>
> Jakub Jelinek <jakub at gcc dot gnu.org> changed:
>
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>            Priority|P3                          |P4
>              Status|UNCONFIRMED                 |NEW
>    Last reconfirmed|                            |2018-01-24
>                  CC|                            |jakub at gcc dot gnu.org,
>                    |                            |pault at gcc dot gnu.org
>      Ever confirmed|0                           |1
>
> --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> Started with r254936.
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
Comment 4 Jakub Jelinek 2018-01-24 22:18:45 UTC
(In reply to paul.richard.thomas@gmail.com from comment #3)
> OK for trunk?

Ok, thanks.
Comment 5 paul.richard.thomas@gmail.com 2018-01-25 19:13:37 UTC
Hi Jakub,

Thanks for the OK and the help in getting the padding sorted out.

Committed as Committed revision 257065.

Paul

On 24 January 2018 at 20:26, Paul Richard Thomas
<paul.richard.thomas@gmail.com> wrote:
> Hi Jakub,
>
> I have made the changes to the types of the dtype elements that you
> suggested. It led to a cast being needed in
> trans-intrinsic.c(gfc_conv_intrinsic_rank) but, apart from that, the
> changes were straightforward. Please find the updated patch attached.
>
> OK for trunk?
>
> Once I have committed this patch, I promise that I will stick to
> regressions and bug fixes through to release :-)
>
> Paul
>
>
> On 24 January 2018 at 09:11, jakub at gcc dot gnu.org
> <gcc-bugzilla@gcc.gnu.org> wrote:
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83999
>>
>> Jakub Jelinek <jakub at gcc dot gnu.org> changed:
>>
>>            What    |Removed                     |Added
>> ----------------------------------------------------------------------------
>>            Priority|P3                          |P4
>>              Status|UNCONFIRMED                 |NEW
>>    Last reconfirmed|                            |2018-01-24
>>                  CC|                            |jakub at gcc dot gnu.org,
>>                    |                            |pault at gcc dot gnu.org
>>      Ever confirmed|0                           |1
>>
>> --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
>> Started with r254936.
>>
>> --
>> You are receiving this mail because:
>> You are on the CC list for the bug.
>
>
>
> --
> "If you can't explain it simply, you don't understand it well enough"
> - Albert Einstein
Comment 6 Jakub Jelinek 2018-05-02 10:11:46 UTC
GCC 8.1 has been released.
Comment 7 Jakub Jelinek 2018-07-26 11:25:42 UTC
GCC 8.2 has been released.
Comment 8 Thomas Koenig 2018-10-06 12:27:58 UTC
For some reason, the array spec is not set for the symbol for z1.f90:

(gdb) p sym->as    
$11 = (gfc_array_spec *) 0x0
(gdb) p sym->name
$12 = 0x7ffff734d0b8 "f"

(with a breakpoint in resolve_fl_procedure).
Comment 9 Paul Thomas 2018-10-06 12:57:48 UTC
Created attachment 44799 [details]
Patch for the PR

For some reason, I do not see the problem on the current 8-branch. In fact, it comes up with the correct error, even though this patch has not been applied!

I will apply to both branches as a belt-and-braces fix :-)

Cheers

Paul
Comment 10 Paul Thomas 2018-10-06 15:15:01 UTC
Author: pault
Date: Sat Oct  6 15:14:29 2018
New Revision: 264899

URL: https://gcc.gnu.org/viewcvs?rev=264899&root=gcc&view=rev
Log:
2018-10-06  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/83999
	* resolve.c (resolve_fl_procedure): Include class functions in
	the test that elemental function results be scalar.

2018-10-06  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/83999
	* gfortran.dg/elemental_function_4.f90 : New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/elemental_function_4.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
Comment 11 Paul Thomas 2018-10-08 14:21:12 UTC
Author: pault
Date: Mon Oct  8 14:20:40 2018
New Revision: 264931

URL: https://gcc.gnu.org/viewcvs?rev=264931&root=gcc&view=rev
Log:
2018-10-08  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/83999
	Backport from trunk
	* resolve.c (resolve_fl_procedure): Include class functions in
	the test that elemental function results be scalar.

2018-10-08  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/83999
	Backport from trunk
	* gfortran.dg/elemental_function_4.f90 : New test.


Added:
    branches/gcc-8-branch/gcc/testsuite/gfortran.dg/elemental_function_4.f90
Modified:
    branches/gcc-8-branch/gcc/fortran/ChangeLog
    branches/gcc-8-branch/gcc/fortran/resolve.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
Comment 12 Paul Thomas 2018-10-08 14:22:14 UTC
Fixed on both branches.

Thanks for the report.

Paul