Bug 39292 - [4.3 Regression] ICE in gfc_conv_array_initializer, at fortran/trans-array.c:3884
Summary: [4.3 Regression] ICE in gfc_conv_array_initializer, at fortran/trans-array.c:...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.4
: P4 normal
Target Milestone: 4.3.4
Assignee: Paul Thomas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-24 16:47 UTC by Richard Biener
Modified: 2009-03-07 15:59 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.4 4.4.0
Known to fail: 4.3.4
Last reconfirmed: 2009-02-26 18:46:01


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2009-02-24 16:47:47 UTC
program bug
         integer :: n
         real, dimension(2) ::&
            &a = (/ ( (float(n))**(1.0), n=1,2) /)
         write(*,*) a(1), a(2)
         stop
      end program bug

gfortran-4.3 -S t.f90 
t.f90: In function ‘bug’:
t.f90:1: internal compiler error: in gfc_conv_array_initializer, at fortran/trans-array.c:3884
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.opensuse.org/> for instructions.
Comment 1 Richard Biener 2009-02-24 16:48:38 UTC
Fails the same with 4.4, 4.2 reports an error:

gfortran-4.2 -S t.f90 
t.f90:4.35:

            &a = (/ ( (float(n))**(1.0), n=1,2) /)
                                  1
Error: Exponent at (1) must be INTEGER for an initialization expression

so I'm not sure if the testcase is valid or not.
Comment 2 kargls 2009-02-24 17:09:26 UTC
(In reply to comment #1)
> Fails the same with 4.4, 4.2 reports an error:
> 
> gfortran-4.2 -S t.f90 
> t.f90:4.35:
> 
>             &a = (/ ( (float(n))**(1.0), n=1,2) /)
>                                   1
> Error: Exponent at (1) must be INTEGER for an initialization expression
> 
> so I'm not sure if the testcase is valid or not.
> 

It is invalid in Fortran 95, and the error message is correct.
It is valid in Fortran 2003.

The patch in 
http://gcc.gnu.org/ml/fortran/2009-01/msg00231.html
may fix your problem.
Comment 3 Paul Thomas 2009-02-24 18:26:11 UTC
Steve,

> The patch in 
> http://gcc.gnu.org/ml/fortran/2009-01/msg00231.html
> may fix your problem.
> 

It does - you are right!  I'll post a response to your patch that it should be applied to 4.4 to fix this regression.

Thanks

Paul
Comment 4 kargls 2009-02-24 19:28:12 UTC
(In reply to comment #3)
> Steve,
> 
> > The patch in 
> > http://gcc.gnu.org/ml/fortran/2009-01/msg00231.html
> > may fix your problem.
> > 
> 
> It does - you are right!  I'll post a response to your patch that it should be
> applied to 4.4 to fix this regression.
> 
> Thanks
> 
> Paul
> 

At this stage in the 4.4 release process, I think my patch is too risky.
I've only done some limited testing.  This should probably be considered
a 4.5 patch.
Comment 5 Paul Thomas 2009-02-25 13:05:09 UTC
Steve,

> 
> At this stage in the 4.4 release process, I think my patch is too risky.
> I've only done some limited testing.  This should probably be considered
> a 4.5 patch.
> 

Should I apply mine, with a check that the expression is constant?

Paul
Comment 6 Paul Thomas 2009-02-26 06:24:08 UTC
Subject: Bug 39292

Author: pault
Date: Thu Feb 26 06:23:42 2009
New Revision: 144444

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144444
Log:
2009-02-26  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39292
	* trans-array.c (gfc_conv_array_initializer): Convert all
	expressions rather than ICEing.

2009-02-26  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39292
	* gfortran.dg/initialization_22.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/initialization_22.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/testsuite/ChangeLog

Comment 7 Paul Thomas 2009-02-26 09:34:10 UTC
Fixed on trunk.

Thanks for the report, Richard

Paul
Comment 8 Richard Biener 2009-02-26 09:37:13 UTC
Not fixed on the branch.  If you don't want to fix it there please adjust
the target milestone appropriately.
Comment 9 Paul Thomas 2009-02-26 10:21:22 UTC
(In reply to comment #8)
> Not fixed on the branch.  If you don't want to fix it there please adjust
> the target milestone appropriately.
> 

Duuuh!

No, that's fine.  I'll give it a few days on trunk and then fix it on 4.3.

Cheers

Paul
Comment 10 Paul Thomas 2009-03-07 15:56:55 UTC
Subject: Bug 39292

Author: pault
Date: Sat Mar  7 15:56:37 2009
New Revision: 144694

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144694
Log:
2009-03-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39292
	* trans-array.c (gfc_conv_array_initializer): Convert all
	expressions rather than ICEing.

2009-03-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39292
	* gfortran.dg/initialization_22.f90: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/initialization_22.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/trans-array.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 11 Paul Thomas 2009-03-07 15:59:42 UTC
Fixed on trunk and 4.3.

Thanks for the report.

Paul