Bug 31253

Summary: ICE in gfc_conv_constant, at fortran/trans-const.c:348
Product: gcc Reporter: Mikael Morin <mikael.morin>
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: dfranke, fxcoudert, gcc-bugs, mikael.morin, P.Schaffnit
Priority: P3 Keywords: accepts-invalid, ice-on-invalid-code
Version: 4.1.2   
Target Milestone: 4.3.0   
Host: Target:
Build: Known to work: 4.3.0
Known to fail: 4.1.1 4.1.2 4.2.0 Last reconfirmed: 2007-03-20 23:51:36
Bug Depends on:    
Bug Blocks: 31392, 31393    
Attachments: the test program that fails
a test program that does not fail

Description Mikael Morin 2007-03-17 21:57:42 UTC
the fortran compiler crashes when trying to compile the following test program : 

      subroutine probleme(p)


      real(kind=8), dimension(:) :: p

      integer :: nx = size(p, 1)
      integer :: nix

      nix = nx
      
      end subroutine




The error reported by the compiler is :

test.f: In function ‘probleme’:
test.f:2: erreur interne du compilateur: dans gfc_conv_constant, à fortran/trans-const.c:348
Veuillez soumettre un rapport complet d'anomalies,
avec le source pré-traité si nécessaire.
Consultez <URL:http://gcc.gnu.org/bugs.html> pour plus de détail.


The compilation command was : gfortran test.f


The gfortran -v is :

Lecture des spécification à partir de /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/specs
Target: x86_64-pc-linux-gnu
Configuré avec: /usr/src/gcc-4.1.2/configure --host=x86_64-pc-linux-gnu --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --enable-threads=posix --with-system-zlib --enable-languages=f95 --disable-multilib
Modèle de thread: posix
version gcc 4.1.2
Comment 1 Mikael Morin 2007-03-17 21:58:59 UTC
Created attachment 13223 [details]
the test program that fails
Comment 2 Mikael Morin 2007-03-17 22:03:34 UTC
the attached program (test.f) fails to compile: 

the compilation command is :
gfortran -c test.f

the error is :
test.f: In function ‘probleme’:
test.f:2: erreur interne du compilateur: dans gfc_conv_constant, à fortran/trans-const.c:348
Veuillez soumettre un rapport complet d'anomalies,
avec le source pré-traité si nécessaire.
Consultez <URL:http://gcc.gnu.org/bugs.html> pour plus de détail.

the fortran version is (gfortran -v) :
Lecture des spécification à partir de /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/specs
Target: x86_64-pc-linux-gnu
Configuré avec: /usr/src/gcc-4.1.2/configure --host=x86_64-pc-linux-gnu --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --enable-threads=posix --with-system-zlib --enable-languages=f95 --disable-multilib
Modèle de thread: posix
version gcc 4.1.2
Comment 3 Thomas Koenig 2007-03-17 22:08:39 UTC
Confirmed with 4.3.0.
Comment 4 Thomas Koenig 2007-03-17 22:10:23 UTC
*** Bug 31252 has been marked as a duplicate of this bug. ***
Comment 5 Mikael Morin 2007-03-18 11:58:49 UTC
Created attachment 13225 [details]
a test program that does not fail
Comment 6 Francois-Xavier Coudert 2007-03-20 23:51:36 UTC
I think test.f is not valid Fortran, because size(p,1) is not a valid specification expression. See 7.1.6 of the F2003 standard: it is a array inquiry function (size) with an argument that is a variable (p) whose properties inquired about *are dependent* on the upper bound of the last dimension of an assumed-size array. So, it's invalid.

Now, we actually accept it because SIZE is a specification inquiry, and we don't check things any further. This part (check_inquiry and its callers in expr.c) need some rewriting to go along with the standard.
Comment 7 Daniel Franke 2007-07-22 16:31:30 UTC
Subject: Bug 31253

Author: dfranke
Date: Sun Jul 22 16:31:11 2007
New Revision: 126826

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126826
Log:
gcc/fortran:
2007-07-22  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/29962
	PR fortran/31253
	PR fortran/31265
	PR fortran/31639
	* gfortran.h (gfc_intrinsic_sym): Changed members elemental, pure,
	generic, specific, actual_ok, noreturn into bits of a bitfield, 
	added bits for inquiry, transformational, conversion.
	* check.c (non_init_transformational): Removed, removed all callers.
	* intrinsic.c (enum class): New.
	(add_sym*): Replaced argument elemetal by enum class. Changed all
	callers.
	(add_functions): Assign appropriate classes to intrinsic functions.
	(add_subroutines): Assign appropriate classes to intrinsic subroutines.
	(add_conv): Set conversion attribute.
	(gfc_init_expr_extensions): Removed, removed all callers.
	(gfc_intrinsic_func_interface): Reimplemented check for non-standard
	initializatione expressions.
	* expr.c (check_specification_function): New.
	(gfc_is_constant_expr): Added check for specification functions.
	(check_init_expr_arguments): New.
	(check_inquiry): Changed return value to MATCH, added checks for
	inquiry functions defined by F2003.
	(check_transformational): New.
	(check_null): New.
	(check_elemental): New.
	(check_conversion): New.
	(check_init_expr): Call new check functions, add more specific error
	messages.

gcc/testsuite:
2007-07-22  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/29962
	* gfortran.dg/array_initializer_1.f90: Removed warning.
	* gfortran.dg/initialization_1.f90: Adjusted messages.
	* gfortran.dg/nested_modules_6.f90: Removed warning.

	PR fortran/31253
	* gfortran.dg/initialization_7.f90: New test.

	PR fortran/31639
	* gfortran.dg/initialization_8.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/initialization_7.f90
    trunk/gcc/testsuite/gfortran.dg/initialization_8.f90
Modified:
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/testsuite/gfortran.dg/array_initializer_1.f90
    trunk/gcc/testsuite/gfortran.dg/initialization_1.f90
    trunk/gcc/testsuite/gfortran.dg/nested_modules_6.f90

Comment 8 Daniel Franke 2007-07-22 16:42:57 UTC
Fixed in trunk. Closing.