Bug 65532 - [5 Regression] Unexpected error with legacy code (D1MACH)
Summary: [5 Regression] Unexpected error with legacy code (D1MACH)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 5.0
: P4 normal
Target Milestone: 5.0
Assignee: Mikael Morin
URL: https://gcc.gnu.org/ml/gcc-patches/20...
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-03-23 22:12 UTC by Harald Anlauf
Modified: 2015-03-26 12:42 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.9.0
Known to fail: 5.0
Last reconfirmed: 2015-03-24 00:00:00


Attachments
Bug demo. (424 bytes, text/x-fortran)
2015-03-23 22:12 UTC, Harald Anlauf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Anlauf 2015-03-23 22:12:24 UTC
Created attachment 35119 [details]
Bug demo.

Dear all,

after updating to trunk rev. 221607, I found a problem which I reduced
to the attached example.

Commenting out the call to d1mach or commenting out in d1mach the
data statements in lines 21-25 makes the error messages disappear.

Here's the error messages I get:

% gfc-trunk -c gfcbug131.f90
gfcbug131.f90:10:23:

     INTEGER :: diver(4)
                       1
Error: Different shape for array assignment at (1) on dimension 1 (4 and 2)
gfcbug131.f90:8:23:

     INTEGER :: large(4)
                       1
Error: Different shape for array assignment at (1) on dimension 1 (4 and 2)
gfcbug131.f90:11:23:

     INTEGER :: LOG10(4)
                       1
Error: Different shape for array assignment at (1) on dimension 1 (4 and 2)
gfcbug131.f90:9:23:

     INTEGER :: right(4)
                       1
Error: Different shape for array assignment at (1) on dimension 1 (4 and 2)
gfcbug131.f90:7:23:

     INTEGER :: small(4)
                       1
Error: Different shape for array assignment at (1) on dimension 1 (4 and 2)
Comment 1 Harald Anlauf 2015-03-23 22:29:52 UTC
I found a workaround by changing the dimension of the arrays in
lines 7-11 to 2 instead of 4 (the original code also supports
dated hardware).
Comment 2 Dominique d'Humieres 2015-03-23 22:49:51 UTC
I suspect r221586: I don't see the errors at r221569.

> I found a workaround by changing the dimension of the arrays in
> lines 7-11 to 2 instead of 4 (the original code also supports
> dated hardware).

Confirmed.
Comment 3 Jakub Jelinek 2015-03-24 06:37:21 UTC
It indeed is r221586.
Comment 4 Mikael Morin 2015-03-24 10:57:12 UTC
With r221586, procedure d1mach is resolved more than once.
At the first time resolve_values is called, the problematic variables (diver, large, etc)  have a NULL sym->value, which is set afterwards in resolve_data.
On the second call, the value is non-null and the error is produced.
Comment 5 ktkachov 2015-03-24 13:38:59 UTC
As noted in 64952, this prevents 481.wrf from SPEC2006 being built
Comment 6 Mikael Morin 2015-03-24 22:47:36 UTC
Patch posted:
https://gcc.gnu.org/ml/gcc-patches/2015-03/msg01272.html
Comment 7 Mikael Morin 2015-03-25 10:16:18 UTC
Author: mikael
Date: Wed Mar 25 10:15:46 2015
New Revision: 221657

URL: https://gcc.gnu.org/viewcvs?rev=221657&root=gcc&view=rev
Log:
Fix regression introduced at revision 221586.

	PR fortran/64952
	PR fortran/65532
fortran/
	* gfortran.h (struct gfc_namespace): New field 'types_resolved'.
	* resolve.c (resolve_types): Return early if field 'types_resolved'
	is set.  Set 'types_resolved' at the end.
testsuite/
	* gfortran.dg/data_initialized_3.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/data_initialized_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
Comment 8 Mikael Morin 2015-03-26 12:42:59 UTC
Fixed.  Closing.