Bug 28384 - ICE on non-existent COMMON block
Summary: ICE on non-existent COMMON block
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-14 19:42 UTC by Paul Thomas
Modified: 2006-07-16 17:18 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-07-15 13:40:25


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Thomas 2006-07-14 19:42:56 UTC
The "program"

      save /rbuf_char/
      end

produces:

0x080b503c in translate_common (common=0xa5005c0, var_list=Variable "var_list" is not available.
)
    at ../../trunk/gcc/fortran/trans-common.c:965
965       if (common_segment->offset != 0)

I propose to fix this directly with

Index: gcc/fortran/trans-common.c
===================================================================
*** gcc/fortran/trans-common.c  (revision 115409)
--- gcc/fortran/trans-common.c  (working copy)
*************** translate_common (gfc_common_head *commo
*** 962,967 ****
--- 962,974 ----
        current_offset += s->length;
      }

+   if (common_segment == NULL)
+     {
+       gfc_error ("COMMON '%s' at %L does not exist",
+                common->name, &common->where);
+       return;
+     }
+
    if (common_segment->offset != 0)
      {
        gfc_warning ("COMMON '%s' at %L requires %d bytes of padding at start",

Paul
Comment 1 Thomas Koenig 2006-07-15 13:40:25 UTC
> Index: gcc/fortran/trans-common.c
> ===================================================================
> *** gcc/fortran/trans-common.c  (revision 115409)
> --- gcc/fortran/trans-common.c  (working copy)
> *************** translate_common (gfc_common_head *commo
> *** 962,967 ****
> --- 962,974 ----
>         current_offset += s->length;
>       }
> 
> +   if (common_segment == NULL)
> +     {
> +       gfc_error ("COMMON '%s' at %L does not exist",
> +                common->name, &common->where);
> +       return;
> +     }
> +
>     if (common_segment->offset != 0)
>       {
>         gfc_warning ("COMMON '%s' at %L requires %d bytes of padding at start",
> 

Yes, please go ahead.  Obvious, really :-)

Thomas

Comment 2 Paul Thomas 2006-07-16 15:02:15 UTC
Subject: Bug 28384

Author: pault
Date: Sun Jul 16 15:01:59 2006
New Revision: 115499

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

	PR fortran/28384
	* trans-common.c (translate_common): If common_segment is NULL
	emit error that common block does not exist.

	PR fortran/20844
	* io.c (check_io_constraints): It is an error if an ADVANCE
	specifier appears without an explicit format.

	PR fortran/28201
	* resolve.c (resolve_generic_s): For a use_associated function,
	do not search for an alternative symbol in the parent name
	space.

	PR fortran/20893
	* resolve.c (resolve_elemental_actual): New function t combine
	all the checks of elemental procedure actual arguments. In
	addition, check of array valued optional args(this PR) has
	been added.
	(resolve_function, resolve_call): Remove parts that treated
	elemental procedure actual arguments and call the above.

2006-07-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/20844
	* gfortran.dg/io_constaints_2.f90: Add the test for ADVANCE
	specifiers requiring an explicit format tag..

	PR fortran/28201
	* gfortran.dg/generic_5: New test.

	PR fortran/20893
	* gfortran.dg/elemental_optional_args_1.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/elemental_optional_args_1.f90
    trunk/gcc/testsuite/gfortran.dg/generic_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/io.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-common.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/io_constraints_2.f90

Comment 3 Paul Thomas 2006-07-16 17:17:33 UTC
Subject: Bug 28384

Author: pault
Date: Sun Jul 16 17:17:04 2006
New Revision: 115502

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

	PR fortran/28384
	* trans-common.c (translate_common): If common_segment is NULL
	emit error that common block does not exist.

	PR fortran/20844
	* io.c (check_io_constraints): It is an error if an ADVANCE
	specifier appears without an explicit format.

	PR fortran/28201
	* resolve.c (resolve_generic_s): For a use_associated function,
	do not search for an alternative symbol in the parent name
	space.

	PR fortran/20893
	* resolve.c (resolve_elemental_actual): New function t combine
	all the checks of elemental procedure actual arguments. In
	addition, check of array valued optional args(this PR) has
	been added.
	(resolve_function, resolve_call): Remove parts that treated
	elemental procedure actual arguments and call the above.

	PR fortran/28353
	* trans-expr.c (gfc_conv_aliased_arg): Missing formal arg means
	that intent is INOUT (fixes regression).

	PR fortran/25097
	* check.c (check_present): The only permitted reference is a
	full array reference.

	PR fortran/20903
	* decl.c (variable_decl): Add error if a derived type is not
	from the current namespace if the namespace is an interface
	body.

2006-07-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/20844
	* gfortran.dg/io_constaints_2.f90: Add the test for ADVANCE
	specifiers requiring an explicit format tag..

	PR fortran/28201
	* gfortran.dg/generic_5: New test.

	PR fortran/20893
	* gfortran.dg/elemental_optional_args_1.f90: New test.

	PR fortran/25097
	* gfortran.dg/present_1.f90: New test.

	PR fortran/20903
	* gfortran.dg/interface_derived_type_1.f90: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/elemental_optional_args_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/generic_5.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/interface_derived_type_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/present_1.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/check.c
    branches/gcc-4_1-branch/gcc/fortran/decl.c
    branches/gcc-4_1-branch/gcc/fortran/io.c
    branches/gcc-4_1-branch/gcc/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/fortran/trans-common.c
    branches/gcc-4_1-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/io_constraints_2.f90

Comment 4 Paul Thomas 2006-07-16 17:18:13 UTC
Fixed on trunk and 4.2

Paul