Bug 27478 - [4.2 Regression] entry and addressable and value-expr: and the gimplifier
Summary: [4.2 Regression] entry and addressable and value-expr: and the gimplifier
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2006-05-08 05:13 UTC by John S. Urban
Modified: 2009-03-30 15:54 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.2 4.2.0 4.3.0
Known to fail:
Last reconfirmed: 2006-10-02 11:35:36


Attachments
script that shows bug + output from running script (1.23 KB, text/plain)
2006-05-08 05:17 UTC, John S. Urban
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John S. Urban 2006-05-08 05:13:34 UTC
#!/bin/sh
cat >bug.f <<\EOF
      FUNCTION TSL(PIN)
!      EXTERNAL PPP
      ENTRY TSL1(PIN)
      IF (DBLE(TSL) .GT. PIN) TSL = 705.47
      TSL= PPP(TSL)
      END
EOF
(
exec 2>&1
uname -a
set -x
gfortran --version 
gfortran -v -c -save-temps bug.f
ls -ltrasd bug*
echo =========================================
cat bug.i*
echo =========================================
#cat bug.s
echo =========================================
) | tee -a $0
exit
########################################################################
CYGWIN_NT-5.1 electra 1.5.12(0.116/4/2) 2004-11-10 08:34 i686 unknown unknown Cygwin
+ gfortran --version
GNU Fortran 95 (GCC) 4.2.0 20060420 (experimental)
Copyright (C) 2006 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

+ gfortran -v -c -save-temps bug.f
Using built-in specs.
Target: i686-pc-cygwin
Configured with: ../trunk/configure --prefix=/irun --with-
mpfr=/usr/local/gmp --with-gmp=/usr/local/gmp --enable-
languages=c,fortran --disable-bootstrap : (reconfigured)
../trunk/configure --prefix=/irun --with-mpfr=/usr/local/gmp --with-
gmp=/usr/local/gmp --enable-languages=c,fortran --disable-bootstrap :
(reconfigured) ../trunk/configure --prefix=/irun --with-
mpfr=/usr/local/gmp --with-gmp=/usr/local/gmp --disable-bootstrap
--enable-languages=c,fortran --no-create --no-recursion : (reconfigured)
../trunk/configure --prefix=/irun --with-mpfr=/usr/local/gmp --with-
gmp=/usr/local/gmp --disable-bootstrap --enable-languages=c,fortran
--no-create --no-recursion : (reconfigured) ../trunk/configure
--prefix=/irun --with-mpfr=/usr/local/gmp --with-gmp=/usr/local/gmp
--disable-bootstrap --enable-languages=c,fortran --no-create --no-
recursion : (reconfigured) ../trunk/configure --prefix=/irun --with-
mpfr=/usr/local/gmp --with-gmp=/usr/local/gmp --disable-bootstrap
--enable-languages=c,fortran --no-create --no-recursion : (reconfigured)
../trunk/configure --prefix=/irun --with-mpfr=/usr/local/gmp --with-
gmp=/usr/local/gmp --disable-bootstrap --enable-languages=c,fortran
--no-create --no-recursion : (reconfigured) ../trunk/configure
--prefix=/irun --with-mpfr=/usr/local/gmp --with-gmp=/usr/local/gmp
--disable-bootstrap --enable-languages=c,fortran --no-create --no-
recursion : (reconfigured) ../trunk/configure --prefix=/irun --with-
mpfr=/usr/local/gmp --with-gmp=/usr/local/gmp --disable-bootstrap
--enable-languages=c,fortran : (reconfigured) ../trunk/configure
--prefix=/irun --with-mpfr=/usr/local/gmp --with-gmp=/usr/local/gmp
--disable-bootstrap --enable-languages=c,fortran --no-create --no-
recursion : (reconfigured) ../trunk/configure --prefix=/irun --with-
mpfr=/usr/local/gmp --with-gmp=/usr/local/gmp --disable-bootstrap
--enable-languages=c,fortran --enable-languages=c,fortran --no-create
--no-recursion : (reconfigured) ../trunk/configure --prefix=/irun
--with-mpfr=/usr/local/gmp --with-gmp=/usr/local/gmp --disable-bootstrap
--enable-languages=c,fortran --enable-languages=c,fortran --no-create
--no-recursion : (reconfigured) ../trunk/configure --prefix=/irun
--with-mpfr=/usr/local/gmp --with-gmp=/usr/local/gmp --disable-bootstrap
--enable-languages=c,fortran --enable-languages=c,fortran --no-create
--no-recursion : (reconfigured) ../trunk/configure --prefix=/irun
--with-mpfr=/usr/local/gmp --with-gmp=/usr/local/gmp --disable-bootstrap
--enable-languages=c,fortran --enable-languages=c,fortran --no-create
--no-recursion
Thread model: single
gcc version 4.2.0 20060420 (experimental)
 /usr/local/irun/bin/../libexec/gcc/i686-pc-cygwin/4.2.0/f951.exe bug.f -ffixed-form -quiet -dumpbase bug.f -mtune=generic -auxbase bug -version -I /usr/local/irun/bin/../lib/gcc/i686-pc-cygwin/4.2.0/finclude -o bug.s
GNU F95 version 4.2.0 20060420 (experimental) (i686-pc-cygwin)
        compiled by GNU C version 3.2 20020927 (prerelease).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
bug.f: In function 'master.0.tsl':
bug.f:5: error: invalid operand to binary operator
__result_master.0.tslD.917

bug.f:5: internal compiler error: verify_stmts failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
+ ls -ltrasd bug.f bug.ksh bug.o bug.s bug1
1 -rw-r--r--  1 urbanjs None 672 Dec 13 23:34 bug.ksh
1 -rw-r--r--  1 urbanjs None 812 Feb 12 23:32 bug1
1 -rw-r--r--  1 urbanjs None 537 May  8 00:44 bug.o
1 -rw-r--r--  1 urbanjs None 139 May  8 00:52 bug.f
1 -rw-r--r--  1 urbanjs None 557 May  8 00:52 bug.s
+ echo =========================================
=========================================
+ cat bug.i*
cat: bug.i*: No such file or directory
+ echo =========================================
=========================================
+ echo =========================================
=========================================

urbanjs@electra ~
$
Comment 1 John S. Urban 2006-05-08 05:17:48 UTC
Created attachment 11400 [details]
script that  shows bug + output from running script
Comment 2 Andrew Pinski 2006-05-08 05:20:37 UTC
As far as I can tell it is a middle-end/gimplifier problem:
  real4 __result_master.0.tsl;
  real4 tsl.0 [value-expr: __result_master.0.tsl];

Unless the value expression should also be marked as TREE_ADDRESSABLE.
Comment 3 Andrew Pinski 2006-06-04 15:16:46 UTC
*** Bug 27889 has been marked as a duplicate of this bug. ***
Comment 4 Francois-Xavier Coudert 2006-06-04 20:58:54 UTC
I'm amazed that 27889 is a duplicate of this bug, although I agree that they have similar error messages. They happen in very different (and specific circumstances). FYI, the testcases from 27889 are:

[on 4.1 at -O1 and higher]
MODULE constraints_module
  REAL target
  CONTAINS
     SUBROUTINE init_constraint
       COMPLEX struc_fac
       CALL set_structure_factor
       RETURN
       CONTAINS
         SUBROUTINE set_structure_factor
           target = CONJG( struc_fac ) * struc_fac
         END SUBROUTINE set_structure_factor
     END SUBROUTINE init_constraint
END MODULE constraints_module

[on 4.2 at any optimization level]
     COMPLEX z
     CONTAINS
       SUBROUTINE foo
         z = z + z
       END SUBROUTINE foo
     END
Comment 5 Andrew Pinski 2006-06-04 21:02:46 UTC
(In reply to comment #4)
> I'm amazed that 27889 is a duplicate of this bug, although I agree that they
> have similar error messages. They happen in very different (and specific
> circumstances). FYI, the testcases from 27889 are:
The value handle is causing the regression but I will reopen that one as I found a C testcase and finding a C testcase for this bug is harder.
Comment 6 Francois-Xavier Coudert 2006-10-02 11:35:36 UTC
That one is annoying. Reduced testcase is:

      FUNCTION X()
      ENTRY X1
      IF (X .GT. 0) CALL FOO(X)
      END

The error message is:

a.f: In function ‘master.0.x’:
a.f:3: error: invalid operand to binary operator
__result_master.0.xD.914

a.f:3: internal compiler error: verify_stmts failed


And the original tree dump is:

x ()
{
  return master.0.x (0);


x1 ()
{
  return master.0.x (1);


master.0.x (__entry)
{
  real4 __result_master.0.x;
  real4 x.0 [value-expr: __result_master.0.x];

  switch (__entry)
    {
      case 0:;
      goto L.2;
      case 1:;
      goto L.4;
    }
  L.2:;
  L.4:;
  if (x.0 > 0.0)
    {
      foo (&x.0);
    }
  else
    {
      (void) 0;
    }
  return __result_master.0.x;
}
Comment 7 Andrew Pinski 2006-10-02 19:39:19 UTC
The gimplifier is going wrong.
It first uses the value-expr and then forgets that can be addressable or maybe even worse we don't mark the result as addressable.
Comment 8 Francois-Xavier Coudert 2006-10-02 20:13:18 UTC
I think the following can workaround the middle-end problem:

Index: trans-decl.c
===================================================================
--- trans-decl.c        (revision 117368)
+++ trans-decl.c        (working copy)
@@ -1866,6 +1866,7 @@
       TREE_PUBLIC (decl) = 0;
       TREE_USED (decl) = 1;
       GFC_DECL_RESULT (decl) = 1;
+      TREE_ADDRESSABLE (decl) = 1;
 
       layout_decl (decl, 0);
Comment 9 patchapp@dberlin.org 2006-10-02 22:15:58 UTC
Subject: Bug number PR 27478

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-10/msg00098.html
Comment 10 Francois-Xavier Coudert 2006-10-03 13:44:21 UTC
Subject: Bug 27478

Author: fxcoudert
Date: Tue Oct  3 13:44:09 2006
New Revision: 117396

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117396
Log:
	PR middle-end/27478

	* trans-decl.c (gfc_get_fake_result_decl): Mark var as
	TREE_ADDRESSABLE.

	* gfortran.dg/entry_8.f90: New test.

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

Comment 11 Mark Mitchell 2007-05-14 22:26:28 UTC
Will not be fixed in 4.2.0; retargeting at 4.2.1.
Comment 12 Mark Mitchell 2007-10-09 19:21:55 UTC
Change target milestone to 4.2.3, as 4.2.2 has been released.
Comment 13 Joseph S. Myers 2008-02-01 16:52:54 UTC
4.2.3 is being released now, changing milestones of open bugs to 4.2.4.
Comment 14 Joseph S. Myers 2008-05-19 20:22:51 UTC
4.2.4 is being released, changing milestones to 4.2.5.
Comment 15 Joseph S. Myers 2009-03-30 15:54:08 UTC
Closing 4.2 branch.  The patch actually went on trunk before 4.2 branched.