Bug 42783 - [4.5 Regression] Bogus Array bounds violation with optional array argument
Summary: [4.5 Regression] Bogus Array bounds violation with optional array argument
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords:
Depends on:
Blocks: 42361
  Show dependency treegraph
 
Reported: 2010-01-17 21:57 UTC by Harald Anlauf
Modified: 2010-01-19 19:48 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.2 4.4.0
Known to fail: 4.5.0
Last reconfirmed: 2010-01-18 17:31:33


Attachments
Bug demo code (fails at runtime) (331 bytes, text/plain)
2010-01-17 21:58 UTC, Harald Anlauf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Anlauf 2010-01-17 21:57:59 UTC
Hi,

when compiled with -fbounds-check, the attached code fails at runtime
with the following error:

At line 8 of file gfcbug99.f90
Fortran runtime error: Actual string length does not match the declared one for dummy argument 'mnem_list' (0/8)

No problem with 4.4.0 or earlier.
Comment 1 Harald Anlauf 2010-01-17 21:58:59 UTC
Created attachment 19643 [details]
Bug demo code (fails at runtime)
Comment 2 Paul Thomas 2010-01-18 17:31:33 UTC
Confirmed.

A weird and wonderful feature of this bug is that it disappears for -O2 and higher :-)

The problem comes about because fsym->backend_decl is being used, which is incorrect if the argument is missing because this does not correspond to the declaration for the string.  Instead, the function gfc_conv_expr_present should be used.

A patch is regtesting right now.

Paul
Comment 3 Paul Thomas 2010-01-19 19:47:16 UTC
Subject: Bug 42783

Author: pault
Date: Tue Jan 19 19:46:59 2010
New Revision: 156046

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

	PR fortran/42783
	* trans-decl.c (add_argument_checking): Do not use the backend
	decl directly to test for the presence of an optional dummy
	argument.  Use gfc_conv_expr_present, remembering to set the
	symbol referenced.

	PR fortran/42772
	* trans-decl.c (gfc_generate_function_code): Small white space
	changes. If 'recurcheckvar' is NULL do not try to reset it.

2010-01-19  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/42783
	* gfortran.dg/bounds_check_15.f90 : New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/bounds_check_15.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Paul Thomas 2010-01-19 19:48:06 UTC
Fixed on trunk.

Thanks for the report.

Paul
Comment 5 hjl@gcc.gnu.org 2010-02-07 04:43:09 UTC
Subject: Bug 42783

Author: hjl
Date: Sun Feb  7 04:41:22 2010
New Revision: 156562

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156562
Log:
Backport testcases from mainline to 4.4.

2010-02-06  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline:
	2010-02-05  Dodji Seketeli  <dodji@redhat.com>

	PR c++/42915
	* g++.dg/other/crash-9.C: New test.

	2010-02-03  Jason Merrill  <jason@redhat.com>

	PR c++/40138
	* g++.dg/ext/builtin11.C: New.

	2010-02-03  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42944
	* gcc.dg/errno-1.c: New testcase.

	2010-02-03  Richard Guenther  <rguenther@suse.de>

	PR middle-end/42927
	* gcc.c-torture/compile/pr42927.c: New testcase.

	2010-01-29  Dodji Seketeli  <dodji@redhat.com>

	PR c++/42758
	PR c++/42634
	PR c++/42336
	PR c++/42797
	PR c++/42880
	* g++.dg/other/crash-5.C: New test.
	* g++.dg/other/crash-7.C: New test.
	* g++.dg/other/crash-8.C: New test.

	2010-01-28  Uros Bizjak  <ubizjak@gmail.com>

	PR target/42891
	* gcc.target/i386/pr42891.c: New test.

	2010-01-28  Richard Guenther  <rguenther@suse.de>

	PR middle-end/42883
	* g++.dg/torture/pr42883.C: New testcase.

	2010-01-28  Michael Matz  <matz@suse.de>

	* gcc.target/i386/pr42881.c: New test.

	2010-01-28  Dodji Seketeli  <dodji@redhat.com>

	PR c++/42713
	PR c++/42820
	* g++.dg/template/typedef27.C: New test case.
	* g++.dg/template/typedef28.C: New test case.

	2010-01-27  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/42874
	* gcc.dg/vla-22.c: New test.

	2010-01-26  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42250
	* gcc.dg/pr42250.c: New testcase.

	2010-01-25  Tobias Burnus  <burnus@net-b.de>

	PR fortran/42858
	* gfortran.dg/generic_21.f90: New test.

	2010-01-21  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/42585
	* gcc.dg/tree-ssa/pr42585.c: New test.

	2010-01-20  Alexandre Oliva  <aoliva@redhat.com>

	PR debug/42715
	* gcc.dg/pr42715.c: New.

	2010-01-20  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42717
	* gcc.c-torture/compile/pr42717.c: New testcase.

	2010-01-19  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/42783
	* gfortran.dg/bounds_check_15.f90 : New test.

	2010-01-18  Dodji Seketeli  <dodji@redhat.com>

	PR c++/42766
	* g++.dg/conversion/op6.C: New test.

	2010-01-18  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42781
	* gfortran.fortran-torture/compile/pr42781.f90: New testcase.

	2010-01-17  Richard Guenther  <rguenther@suse.de>

	PR middle-end/42248
	* gcc.c-torture/execute/pr42248.c: New testcase.

	2010-01-17  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/42677
	* gfortran.dg/interface_assignment_5.f90: New test.

	2010-01-15  Richard Guenther  <rguenther@suse.de>

	PR middle-end/42739
	* g++.dg/torture/pr42739.C: New testcase.

	2010-01-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR fortran/42684
	* gfortran.dg/interface_31.f90: New test.

	2010-01-14  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/42706
	* gcc.dg/ipa/pr42706.c: New testcase.

	2010-01-14  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/42714
	* g++.dg/torture/pr42714.C: New test.

	2010-01-14  Alexander Monakov  <amonakov@ispras.ru>

	PR rtl-optimization/42388
	* gcc.dg/pr42388.c: New.

	2010-01-14  Alexander Monakov <amonakov@ispras.ru>

	PR rtl-optimization/42294
	* gfortran.dg/pr42294.f: New.

	2010-01-14  Ira Rosen  <irar@il.ibm.com>

	PR tree-optimization/42709
	* gcc.dg/vect/pr42709.c: New test.

	2010-01-13  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42730
	* gcc.c-torture/compile/pr42730.c: New testcase.

	2010-01-13  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/42704
	* g++.dg/torture/pr42704.C: New test.

	2010-01-13  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/42703
	* gcc.c-torture/compile/pr42703.c: New test.

	2010-01-13  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42705
	* gcc.c-torture/compile/pr42705.c: New testcase.

	2010-01-13  Richard Guenther  <rguenther@suse.de>

	PR middle-end/42716
	* gcc.c-torture/compile/pr42716.c: New testcase.

	2010-01-12  Joseph Myers  <joseph@codesourcery.com>

	PR c/42708
	* gcc.c-torture/compile/pr42708-1.c: New test.

	2010-01-09  Alexandre Oliva  <aoliva@redhat.com>

	PR middle-end/42363
	* gcc.dg/torture/pr42363.c: New.

	2010-01-09  Alexandre Oliva  <aoliva@redhat.com>

	PR debug/42604
	PR debug/42395
	* gcc.dg/vect/pr42604.c: New.
	* gcc.dg/vect/pr42395.c: New.

	2010-01-09  Richard Guenther  <rguenther@suse.de>

	PR middle-end/42512
	* gcc.c-torture/execute/pr42512.c: New testcase.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/conversion/op6.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/conversion/op6.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ext/builtin11.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/ext/builtin11.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/other/crash-5.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/other/crash-5.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/other/crash-7.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/other/crash-7.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/other/crash-8.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/other/crash-8.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/other/crash-9.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/other/crash-9.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/typedef27.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/template/typedef27.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/typedef28.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/template/typedef28.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42704.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/torture/pr42704.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42714.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/torture/pr42714.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42739.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/torture/pr42739.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42883.C
      - copied unchanged from r156561, trunk/gcc/testsuite/g++.dg/torture/pr42883.C
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42703.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42703.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42705.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42705.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42708-1.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42708-1.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42716.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42716.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42717.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42717.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42730.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42730.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42927.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/compile/pr42927.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr42248.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/execute/pr42248.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr42512.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.c-torture/execute/pr42512.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/errno-1.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/errno-1.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/ipa/pr42706.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/ipa/pr42706.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr42250.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/pr42250.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr42388.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/pr42388.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr42715.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/pr42715.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/torture/pr42363.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/torture/pr42363.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/tree-ssa/pr42585.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/tree-ssa/pr42585.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/pr42395.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/vect/pr42395.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/pr42604.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/vect/pr42604.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/pr42709.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/vect/pr42709.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vla-22.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.dg/vla-22.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr42881.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.target/i386/pr42881.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr42891.c
      - copied unchanged from r156561, trunk/gcc/testsuite/gcc.target/i386/pr42891.c
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/bounds_check_15.f90
      - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.dg/bounds_check_15.f90
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/generic_21.f90
      - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.dg/generic_21.f90
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/interface_31.f90
      - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.dg/interface_31.f90
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/interface_assignment_5.f90
      - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.dg/interface_assignment_5.f90
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/pr42294.f
      - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.dg/pr42294.f
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.fortran-torture/compile/pr42781.f90
      - copied unchanged from r156561, trunk/gcc/testsuite/gfortran.fortran-torture/compile/pr42781.f90
Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog