Bug 25018 - Segfault with simple expression
Summary: Segfault with simple expression
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2005-11-24 13:29 UTC by Tobias Schlüter
Modified: 2006-01-01 05:31 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-11-25 15:11:47


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Schlüter 2005-11-24 13:29:29 UTC
schluter@pcl247d:~/src/work> cat const.f90
module const
  real(8), parameter :: g = - sqrt(2._8) * Gf
end module const
schluter@pcl247d:~/src/work> ../gcc/build/gcc/f951 const.f90
const.f90:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
schluter@pcl247d:~/src/work> 
The uninitialized variable is necessary for the segfault.  In the debugger:
(gdb) run const.f90
Starting program: /home/pcl331/schluter/src/gcc/build/gcc/f951 const.f90

Program received signal SIGSEGV, Segmentation fault.
0x0805efad in check_inquiry (e=0x8695ad0) at ../../gcc/fortran/expr.c:1382
1382   name = e->symtree->n.sym->name;
(gdb) bt
#0  0x0805efad in check_inquiry (e=0x8695ad0) at ../../gcc/fortran/expr.c:1382
#1  0x0806082b in check_init_expr (e=0x8695ad0) at ../../gcc/fortran/expr.c:1443
#2  0x0805edc6 in check_intrinsic_op (e=0x8695b28, check_function=0x80607c0 <check_init_expr>)
    at ../../gcc/fortran/expr.c:1284
#3  0x0806081d in check_init_expr (e=0x8695b28) at ../../gcc/fortran/expr.c:1434
#4  0x0805ed32 in check_intrinsic_op (e=0x8695c78, check_function=0x80607c0 <check_init_expr>)
    at ../../gcc/fortran/expr.c:1250
#5  0x0806081d in check_init_expr (e=0x8695c78) at ../../gcc/fortran/expr.c:1434
#6  0x0805ed32 in check_intrinsic_op (e=0x8695cd0, check_function=0x80607c0 <check_init_expr>)
    at ../../gcc/fortran/expr.c:1250
#7  0x0806081d in check_init_expr (e=0x8695cd0) at ../../gcc/fortran/expr.c:1434
#8  0x08060a52 in gfc_match_init_expr (result=0xbfffed64) at ../../gcc/fortran/expr.c:1543
#9  0x08059f00 in variable_decl (elem=Variable "elem" is not available.
) at ../../gcc/fortran/decl.c:1209
#10 0x0805aa82 in gfc_match_data_decl () at ../../gcc/fortran/decl.c:2240
#11 0x0807ec0a in match_word (str=Variable "str" is not available.
) at ../../gcc/fortran/parse.c:65
#12 0x0807ed1d in decode_statement () at ../../gcc/fortran/parse.c:134
#13 0x0807f745 in next_statement () at ../../gcc/fortran/parse.c:358
#14 0x08080a5b in parse_spec (st=ST_NONE) at ../../gcc/fortran/parse.c:1556
#15 0x080815f9 in gfc_parse_file () at ../../gcc/fortran/parse.c:2501
#16 0x0809cadd in gfc_be_parse_file (set_yydebug=0) at ../../gcc/fortran/f95-lang.c:286
#17 0x0836cf40 in toplev_main (argc=2, argv=0xbfffefd4) at ../../gcc/toplev.c:990
#18 0x080c766f in main (argc=Cannot access memory at address 0x0
) at ../../gcc/main.c:35
(gdb)
Comment 1 eedelman 2005-11-25 15:11:47 UTC
Confirmed.
Comment 2 Paul Thomas 2005-12-18 14:01:05 UTC
Subject: Bug 25018

Author: pault
Date: Sun Dec 18 14:01:00 2005
New Revision: 108753

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

	PR fortran/25018
	*expr.c(check_inquiry): Return FAILURE if there is no symtree to
	provide a name. Error/warning for assumed character length argument
	to LEN for an initialization expression, using GFC_GNU_STD. Add an
	argument to flag that the expression is not restricted.
	(check_init_expr): Improve the message for a failing variable.
	(gfc_match_init_expr): Call check_enquiry again to make sure that
	unsimplified expressions are not causing unnecessary errors.

2005-12-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25018
	*gfortran.dg/initialization_1.f90: New test.
	*gfortran.dg/enum_5.f90: Change dg-error to new message.
	*gfortran.dg/g77/980616-0.f: The same.

Added:
    trunk/gcc/testsuite/gfortran.dg/initialization_1.f90
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/enum_5.f90
    trunk/gcc/testsuite/gfortran.dg/g77/980616-0.f

Comment 3 Paul Thomas 2005-12-26 09:07:35 UTC
Fixed on trunk and 4.1
Comment 4 Paul Thomas 2005-12-26 09:07:47 UTC
Subject: Bug 25018

Author: pault
Date: Mon Dec 26 09:07:27 2005
New Revision: 109061

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

	PR fortran/20889
	*resolve.c(resolve_structure_cons): Do not attempt to convert
	the type of mismatched pointer type components, except when
	the constructor component is BT_UNKNOWN; emit error instead.

	PR fortran/25018
	* expr.c (check_inquiry): Return FAILURE if there is no symtree to
	provide a name. Error/warning for assumed character length argument
	to LEN for an initialization expression, using GFC_GNU_STD. Add an
	argument to flag that the expression is not restricted.
	(check_init_expr): Improve the message for a failing variable.
	(gfc_match_init_expr): Call check_enquiry again to make sure that
	unsimplified expressions are not causing unnecessary errors.

	PR fortran/19362
	PR fortran/20244
	PR fortran/20864
	PR fortran/25391
	* interface.c (gfc_compare_types): Broken into two.
	(gfc_compare_derived_types): Second half of gfc_compare_types with
	corrections for a missing check that module name is non-NULL and
	a check for private components.
	* symbol.c (gfc_free_dt_list): New function.
	(gfc_free_namespace): Call gfc_free_dt_list.
	* resolve.c (resolve_symbol): Build the list of derived types in the
	symbols namespace.
	* gfortran.h: Define the structure type gfc_dt_list.  Add a new field,
	derived_types to gfc_namespace.  Provide a prototye for the new
	function gfc_compare_derived_types.
	* trans_types.c (gfc_get_derived_type): Test for the derived type being
	available in the host namespace. In this case, the host backend
	declaration is used for the structure and its components.  If an
	unbuilt, equal structure that is not use associated is found in the
	host namespace, build it there and then.  On exit,traverse the
	namespace of the derived type to see if there are equal but unbuilt.
	If so, copy the structure and its component declarations.
	(copy_dt_decls_ifequal): New functions to copy declarations to other
	equal structure types.

	PR fortran/20862
	* io.c (gfc_match_format): Make the appearance of a format statement
	in a module specification block an error.

	PR fortran/23152
	* match.c (gfc_match_namelist): Set assumed shape arrays in
	namelists as std=GFC_STD_GNU and assumed size arrays as an
	unconditional error.

	PR fortran/25069
	* match.c (gfc_match_namelist): Set the respecification of a USE
	associated namelist group as std=GFC_STD_GNU.  Permit the concatenation
	on no error.

	PR fortran/25053
	PR fortran/25063
	PR fortran/25064
	PR fortran/25066
	PR fortran/25067
	PR fortran/25068
	PR fortran/25307
	* io.c (resolve_tag): Change std on IOSTAT != default integer to
	GFC_STD_GNU and change message accordingly.  Add same error for
	SIZE.
	(match_dt_element, gfortran.h): Add field err_where to gfc_dt and
	set it when tags are being matched.
	(gfc_resolve_dt): Remove tests that can be done before resolution
	and add some of the new ones here.
	(check_io_constraints): New function that checks for most of the
	data transfer constraints. Some of these were previously done in
	match_io, from where this function is called, and some were done
	in gfc_resolve_dt.
	(match_io): Remove most of the tests of constraints and add the
	call to check_io_constraints.

2005-12-26  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/20889
	* gfortran.dg/pointer_component_type_1.f90: New test.

	PR fortran/25018
	* gfortran.dg/initialization_1.f90: New test.
	* gfortran.dg/enum_5.f90: Change dg-error to new message.
	* gfortran.dg/g77/980616-0.f: The same.

	PR fortran/19362
	PR fortran/20244
	PR fortran/20864
	PR fortran/25391
	*gfortran.dg/used_dummy_types_1.f90: New test.
	*gfortran.dg/used_dummy_types_2.f90: New test.
	*gfortran.dg/used_dummy_types_3.f90: New test.
	*gfortran.dg/used_dummy_types_4.f90: New test.
	*gfortran.dg/used_dummy_types_5.f90: New test.

	PR fortran/23152
	* gfortran.dg/namelist_use.f90: Add trap for warning on NAMELIST
	group already being USE associated.
	* gfortran.dg/assumed_shape_nml.f90: New test.
	* gfortran.dg/assumed_size_nml.f90: New test.

	PR fortran/20862
	PR fortran/25053
	PR fortran/25063
	PR fortran/25064
	PR fortran/25066
	PR fortran/25067
	PR fortran/25068
	PR fortran/25307
	* gfortran.dg/io_constraints_1.f90: New test.
	* gfortran.dg/io_constraints_1.f90: New test.
	* gfortran.dg/iostat_3.f90: Change wording of warning.
	* gfortran.dg/g77/19981216-0.f:  the same.

Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/expr.c
    branches/gcc-4_1-branch/gcc/fortran/gfortran.h
    branches/gcc-4_1-branch/gcc/fortran/interface.c
    branches/gcc-4_1-branch/gcc/fortran/io.c
    branches/gcc-4_1-branch/gcc/fortran/match.c
    branches/gcc-4_1-branch/gcc/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/fortran/symbol.c
    branches/gcc-4_1-branch/gcc/fortran/trans-types.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/enum_5.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/g77/19981216-0.f
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/g77/980616-0.f
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/namelist_use.f90

Comment 5 Paul Thomas 2005-12-29 06:18:35 UTC
Subject: Bug 25018

Author: pault
Date: Thu Dec 29 06:18:23 2005
New Revision: 109139

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

	PR fortran/25532
	* trans-types.c (copy_dt_decls_ifequal): Copy declarations for
	components of derived type components by recursing into
	gfc_get_derived_type.

2005-12-29  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25532
	*gfortran.dg/host_used_types_1.f90: Check that host associated
	derived type components of derived types are properly declared
	in contained procedures.

	The following tests were not added on the 2005-12-26 commit.

	PR fortran/20889
	* gfortran.dg/pointer_component_type_1.f90: New test.

	PR fortran/25018
	* gfortran.dg/initialization_1.f90: New test.

	PR fortran/19362
	PR fortran/20244
	PR fortran/20864
	PR fortran/25391
	* gfortran.dg/used_dummy_types_1.f90: New test.
	* gfortran.dg/used_dummy_types_2.f90: New test.
	* gfortran.dg/used_dummy_types_3.f90: New test.
	* gfortran.dg/used_dummy_types_4.f90: New test.
	* gfortran.dg/used_dummy_types_5.f90: New test.

	PR fortran/23152
	* gfortran.dg/assumed_shape_nml.f90: New test.
	* gfortran.dg/assumed_size_nml.f90: New test.

	PR fortran/20862
	PR fortran/25053
	PR fortran/25063
	PR fortran/25064
	PR fortran/25066
	PR fortran/25067
	PR fortran/25068
	PR fortran/25307
	* gfortran.dg/io_constraints_1.f90: New test.
	* gfortran.dg/io_constraints_1.f90: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/assumed_shape_nml.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/assumed_size_nml.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/host_used_types_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/initialization_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/io_constraints_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/io_constraints_2.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/pointer_component_type_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_dummy_types_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_dummy_types_2.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_dummy_types_3.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_dummy_types_4.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_dummy_types_5.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/trans-types.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog