Bug 29758 - Runtime segfault in RESHAPE with insufficient elements in SOURCE
Summary: Runtime segfault in RESHAPE with insufficient elements in SOURCE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2006-11-08 05:52 UTC by Paul Thomas
Modified: 2006-11-12 07:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-11-08 22:38:24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Thomas 2006-11-08 05:52:57 UTC
$ cat ../prs/reshape.f90
   real :: a(2,2), z = 1.0
   a = reshape ([z], [2,2])
end

Paul@NONE-X6EIN5I8FN /home/pr29431
$ /irun/bin/gfortran ../prs/reshape.f90

Paul@NONE-X6EIN5I8FN /home/pr29431
$ ./a
Segmentation fault (core dumped)

I have a partial fix that breaks two testsuite cases; I expect that it will be done in the next day or two.

Paul
Comment 1 patchapp@dberlin.org 2006-11-09 00:20:36 UTC
Subject: Bug number PR29758

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-11/msg00531.html
Comment 2 Paul Thomas 2006-11-10 21:06:52 UTC
Subject: Bug 29758

Author: pault
Date: Fri Nov 10 21:06:42 2006
New Revision: 118664

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118664
Log:
2006-11-10 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/29758
   * check.c (gfc_check_reshape): Check that there are enough
   elements in the source array as to be able to fill an array
   defined by shape, when pad is absent.


2006-11-10 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/29758
   * gfortran.dg/reshape_source_size_1.f90: New test.




Added:
    trunk/gcc/testsuite/gfortran.dg/reshape_source_size_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 Paul Thomas 2006-11-12 07:40:47 UTC
Subject: Bug 29758

Author: pault
Date: Sun Nov 12 07:40:26 2006
New Revision: 118719

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118719
Log:
2006-11-12 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29699
	* trans-array.c (structure_alloc_comps): Detect pointers to
	arrays and use indirect reference to declaration.
	* resolve.c (resolve_fl_variable): Tidy up condition.
	(resolve_symbol): The same and only add initialization code if
	the symbol is referenced.
	* trans-decl.c (gfc_trans_deferred_vars): Call gfc_trans_
	deferred_array before gfc_trans_auto_array_allocation.

	PR fortran/21730
	* symbol.c (check_done): Remove.
	(gfc_add_attribute): Remove reference to check_done and remove
	the argument attr_intent.
	(gfc_add_allocatable, gfc_add_dimension, gfc_add_external,
	gfc_add_intrinsic, gfc_add_optional, gfc_add_pointer,
	gfc_add_cray_pointer, gfc_add_cray_pointee, gfc_add_result,
	gfc_add_target, gfc_add_in_common, gfc_add_elemental,
	gfc_add_pure, gfc_add_recursive, gfc_add_procedure,
	gfc_add_type): Remove references to check_done.
	* decl.c (attr_decl1): Eliminate third argument in call to
	gfc_add_attribute.
	* gfortran.h : Change prototype for gfc_add_attribute.

	PR fortran/29431
	* trans-array.c    (get_array_ctor_strlen): If we fall through to
	default, use a constant character length if it is available.

	PR fortran/29758
	* check.c (gfc_check_reshape): Check that there are enough
	elements in the source array as to be able to fill an array
	defined by shape, when pad is absent.

	PR fortran/29315
	* trans-expr.c (is_aliased_array): Treat correctly the case where the
	component is itself and array or array reference.


2006-11-12 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29699
	* gfortran.dg/alloc_comp_auto_array_1.f90: New test.

	PR fortran/21730
	* gfortran.dg/change_symbol_attributes_1.f90: New test.

	PR fortran/29431
	* gfortran.dg/array_constructor_13.f90: New test.

	PR fortran/29758
	* gfortran.dg/reshape_source_size_1.f90: New test.

	PR fortran/29315
	* gfortran.dg/aliasing_dummy_4.f90: New test.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/aliasing_dummy_4.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_1.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/array_constructor_13.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/change_symbol_attributes_1.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/reshape_source_size_1.f90
Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/check.c
    branches/gcc-4_2-branch/gcc/fortran/decl.c
    branches/gcc-4_2-branch/gcc/fortran/gfortran.h
    branches/gcc-4_2-branch/gcc/fortran/resolve.c
    branches/gcc-4_2-branch/gcc/fortran/symbol.c
    branches/gcc-4_2-branch/gcc/fortran/trans-array.c
    branches/gcc-4_2-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_2-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 4 Paul Thomas 2006-11-12 07:43:30 UTC
Fixed on trunk and 4.2. 4.1 will follow next weekend.

Paul
Comment 5 Paul Thomas 2006-11-12 07:46:33 UTC
I'd better mark it fixed too....