User account creation filtered due to spam.

Bug 30408 - [gfortran, 4.3 regression]: ICE on valid with -Wall
Summary: [gfortran, 4.3 regression]: ICE on valid with -Wall
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 30405 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-01-08 13:07 UTC by Martin Reinecke
Modified: 2007-01-10 19:20 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 4.2.0
Known to fail: 4.3.0
Last reconfirmed: 2007-01-08 13:26:55


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Reinecke 2007-01-08 13:07:48 UTC
Current mainline gfortran ICEs when compiling the following code with -Wall:

module linebufmod
implicit none

type linebuf
  character(len=80), dimension(:), pointer :: data=>NULL()
end type linebuf

contains

subroutine linebuf_add (buf)
  type(linebuf), intent(inout) :: buf

  buf%data(1) = "blah"
end subroutine linebuf_add

end module linebufmod


~/tmp>gfortran -v -c linebufmod.F90 -Wall
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /scratch/martin/gcc/configure --prefix=/afs/mpa/data/martin/ugcc --enable-languages=c++,fortran
Thread model: posix
gcc version 4.3.0 20070108 (experimental)
 /afs/mpa/data/martin/ugcc/libexec/gcc/i686-pc-linux-gnu/4.3.0/cc1 -E -lang-fortran -traditional-cpp -D_LANGUAGE_FORTRAN -quiet -v linebufmod.F90 -mtune=generic -Wall -o /tmp/ccEpYWVk.f95
ignoring nonexistent directory "/afs/mpa/data/martin/ugcc/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /afs/mpa/data/martin/ugcc/include
 /afs/mpa/data/martin/ugcc/lib/gcc/i686-pc-linux-gnu/4.3.0/include
 /usr/include
End of search list.
 /afs/mpa/data/martin/ugcc/libexec/gcc/i686-pc-linux-gnu/4.3.0/f951 /tmp/ccEpYWVk.f95 -ffree-form -quiet -dumpbase linebufmod.F90 -mtune=generic -auxbase linebufmod -Wall -version -fpreprocessed -fintrinsic-modules-path /afs/mpa/data/martin/ugcc/lib/gcc/i686-pc-linux-gnu/4.3.0/finclude -o /tmp/cc0Iohmw.s
GNU F95 version 4.3.0 20070108 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.3.0 20070108 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
linebufmod.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.
Comment 1 Tobias Burnus 2007-01-08 13:26:55 UTC
0x000000000044fe6e in resolve_code (code=0xe2f690, ns=0xe2eb60) at fortran/resolve.c:5097
5097                  if (sym->ts.cl->length->expr_type == EXPR_CONSTANT)
(gdb) bt
#1  0x000000000045042d in resolve_codes (ns=0xe24b90) at fortran/resolve.c:7278
#2  0x0000000000450495 in gfc_resolve (ns=0xe24b90) at fortran/resolve.c:7302
Comment 2 kargl 2007-01-08 17:42:15 UTC
This compiles with 
laptop:kargl[218] gfc4x --version
GNU Fortran 95 (GCC) 4.3.0 20061228 (experimental)
Copyright (C) 2006 Free Software Foundation, Inc.
Comment 3 kargl 2007-01-08 18:55:36 UTC
This is related to an undocumented warning flag.  In options.c, gfortran sets
several warnings to on.  One of these is

  gfc_option.warn_character_truncation = 1;

If I change this to 0, then your code with -Wall compiles.  Fortunately,
gfc_option.warn_character_truncation appears only in decl.c and
resolve.c, and occurs exactly once in both files.  A few things need to
occur:
  1) Add a -W[no-]character-truncation option.
  2) Document the option.
  3) Fix Martin's bug
Comment 4 Jerry DeLisle 2007-01-09 06:10:34 UTC
*** Bug 30405 has been marked as a duplicate of this bug. ***
Comment 5 Jerry DeLisle 2007-01-10 04:34:49 UTC
Subject: Bug 30408

Author: jvdelisle
Date: Wed Jan 10 04:34:34 2007
New Revision: 120632

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=120632
Log:
2007-01-09  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30408
	* resolve.c (resolve_code): Use the code->expr character length
	directly to set length of llen.

2007-01-09  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/30408
	* lang.opt: Add Wcharacter_truncation option.
	* options.c (gfc_init_options): Initialize
	gfc_option.warn_character_truncation to zero.
	(gfc_handle_option): Add case for OPT_Wcharacter_truncation.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/lang.opt
    trunk/gcc/fortran/options.c
    trunk/gcc/fortran/resolve.c

Comment 6 Andrew Pinski 2007-01-10 19:20:55 UTC
Fixed.
Comment 7 Paul Thomas 2007-01-14 14:50:18 UTC
Subject: Bug 30408

Author: pault
Date: Sun Jan 14 14:49:50 2007
New Revision: 120772

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=120772
Log:
2007-01-14  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
	    Paul Thomas  <pault@gcc.gnu.org>

	Back port from trunk

	PR fortran/30408
	* lang.opt: Add Wcharacter_truncation option.
	* options.c (gfc_init_options): Initialize
	gfc_option.warn_character_truncation to zero.
	(gfc_handle_option): Add case for OPT_Wcharacter_truncation.

	PR fortran/30408
	* resolve.c (resolve_code): Use the code->expr character length
	directly to set length of llen.

2007-01-14  Paul Thomas  <pault@gcc.gnu.org>

	Backports from trunk

	PR fortran/23232
	* decl.c (gfc_in_match_data, gfc_set_in_match_data): New
	functions to signal that a DATA statement is being matched.
	(gfc_match_data): Call gfc_set_in_match_data on entry and on
	exit.
	* gfortran.h : Add prototypes for above.
	* expr.c (check_init_expr): Avoid check on parameter or
	variable if gfc_in_match_data is true.
	(gfc_match_init_expr): Do not call error on non-reduction of
	expression if gfc_in_match_data is true.

	PR fortran/27996
	PR fortran/27998
	* decl.c (gfc_set_constant_character_len): Add boolean arg to
	flag array constructor resolution.  Warn if string is being
	truncated.  Standard dependent error if string is padded. Set
	new arg to false for all three calls to
	gfc_set_constant_character_len.
	* match.h : Add boolean arg to prototype for
	gfc_set_constant_character_len.
	* gfortran.h : Add warn_character_truncation to gfc_options.
	* options.c (set_Wall): Set warn_character_truncation if -Wall
	is set.
	* resolve.c (resolve_code): Warn if rhs string in character
	assignment has to be truncated.
	* array.c (gfc_resolve_character_array_constructor): Set new
	argument to true for call to gfc_set_constant_character_len.

	PR fortran/30410
	* trans-decl.c (gfc_sym_mangled_function_id): Module, external
	symbols must not have the module name prepended.

2007-01-14  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/23232
	* gfortran.dg/data_implied_do_1.f90: New test.

	PR fortran/27996
	PR fortran/27998
	* gfortran.dg/char_length_1.f90: New test.

	PR fortran/30410
	* gfortran.dg/external_procedures_2.f90: New test.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/char_length_1.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/data_implied_do_1.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/external_procedures_2.f90
Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/array.c
    branches/gcc-4_2-branch/gcc/fortran/decl.c
    branches/gcc-4_2-branch/gcc/fortran/expr.c
    branches/gcc-4_2-branch/gcc/fortran/gfortran.h
    branches/gcc-4_2-branch/gcc/fortran/lang.opt
    branches/gcc-4_2-branch/gcc/fortran/match.h
    branches/gcc-4_2-branch/gcc/fortran/options.c
    branches/gcc-4_2-branch/gcc/fortran/resolve.c
    branches/gcc-4_2-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog