Bug 68055 - ICE on using unsupported kinds in program without program statement
Summary: ICE on using unsupported kinds in program without program statement
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 5.2.1
: P3 normal
Target Milestone: 5.3
Assignee: kargls
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-22 17:20 UTC by Gerhard Steinmetz
Modified: 2015-10-29 20:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-10-23 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard Steinmetz 2015-10-22 17:20:22 UTC
Without an explicit program statement :

$ cat z1.f90
!program p
   real*9 :: c
   write (c, '(i3)') 1
end


$ gfortran -g -O0 -Wall -fcheck=all z1.f90
f951: internal compiler error: gfc_validate_kind(): Got bad kind

---

Detected with program statement :

$ cat z2.f90
program p
   real*9 :: c
   write (c, '(i3)') 1
end


$ gfortran -g -O0 -Wall -fcheck=all z2.f90
z2.f90:2:9:

    real*9 :: c
         1
Error: Old-style type declaration REAL*9 not supported at (1)
z2.f90:3:10:

    write (c, '(i3)') 1
          1
Error: UNIT specification at (1) must be an INTEGER expression or a CHARACTER variable
Comment 1 Gerhard Steinmetz 2015-10-22 19:31:59 UTC
Simplified. Still different behaviour :

$ cat z3.f90
!program p
   integer*3 c
   print *, c
end

$ gfortran -g -O0 -Wall -fcheck=all z3.f90
z3.f90:2:0:

    integer*3 c
 1
internal compiler error: Segmentation fault
Comment 2 kargls 2015-10-23 23:25:47 UTC
I could not generate an ICE with z1.f90.  Instead, I
the following error:

% gfc6 -c g1.f90
g1.f90:3:7:

    c = 1
       1
Error: Can't convert INTEGER(4) to INTEGER(3) at (1)

with gcc 4.9.x, 5.2.x, and 6.  gfortran should reject
the *3.  I have a patch that does now does

% gfc6 -c g1.f90
g1.f90:2:12:

    integer*3 c
            1
Error: Old-style type declaration INTEGER*3 not supported at (1)
Comment 3 Steve Kargl 2015-10-23 23:54:21 UTC
Patch posted at 

https://gcc.gnu.org/ml/fortran/2015-10/msg00112.html

As I don't see an ICE, Gerhard can you test this?
Comment 4 kargls 2015-10-24 17:10:07 UTC
Author: kargl
Date: Sat Oct 24 17:09:35 2015
New Revision: 229288

URL: https://gcc.gnu.org/viewcvs?rev=229288&root=gcc&view=rev
Log:
2015-10-24  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68055
	* decl.c (gfc_match_decl_type_spec): Check for valid kind in old-style
	declarations.

2015-10-24  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68055
	* gfortran.dg/pr68055.f90: New case.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr68055.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Gerhard Steinmetz 2015-10-26 15:40:34 UTC
Sorry for answering late, but most of the time I am "offline" 
from several streams. 

Up to now I'm using mostly precompiled/configured packages from 
SUSE, currently gcc version 5.2.1 (+r228597). For several reasons,
I'm avoiding self-compiled versions, including gcc/gfortran.  
Hence my efforts are limited to black box tests and validations.

But of course I will test more on this issue with newly available
packages from software.opensuse.org as soon as possible.

Thank you very much for the continuing development and great support.
Comment 6 kargls 2015-10-29 20:44:41 UTC
Author: kargl
Date: Thu Oct 29 20:44:09 2015
New Revision: 229560

URL: https://gcc.gnu.org/viewcvs?rev=229560&root=gcc&view=rev
Log:
2015-10-29  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68055
	* decl.c (gfc_match_decl_type_spec): Check for valid kind in old-style
	declarations.

2015-10-29  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68055
	* gfortran.dg/pr68055.f90: New case.

Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/pr68055.f90
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/decl.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 7 kargls 2015-10-29 20:45:30 UTC
Fixed on trunk and 5-branch.  Thanks for the bug report.