Bug 53691 - [4.7/4.8 Regression] ICE with -Wsurprising in LAPACK 3.4.1 cgbrfsx.f
Summary: [4.7/4.8 Regression] ICE with -Wsurprising in LAPACK 3.4.1 cgbrfsx.f
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.7.1
: P3 normal
Target Milestone: 4.7.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-15 19:49 UTC by foldy
Modified: 2012-06-22 10:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-06-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description foldy 2012-06-15 19:49:13 UTC
fl_g77 -c -m64 -mtune=generic -Wall -Wstrict-aliasing=3 -O3 -fomit-frame-pointer -fPIC cgbrfsx.f
cgbrfsx.f:519.23:

            REF_TYPE = PARAMS( LA_LINRX_ITREF_I )                       
                       1
Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1)
f951: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

fl_g77 -v:

Using built-in specs.
COLLECT_GCC=fl_g77
COLLECT_LTO_WRAPPER=/home/devel/libexec/gcc/x86_64-pc-linux-gnu/4.7.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-4.7.1/configure --prefix=/home/devel --build=x86_64-pc-linux-gnu --enable-languages=c,c++,fortran --enable-long-long --enable-threads --enable-__cxa_atexit --with-gmp=/home/devel --with-mpfr=/home/devel --without-ppl --without-cloog --disable-multilib --disable-nls --program-suffix=-4.7.1
Thread model: posix
gcc version 4.7.1 (GCC)
Comment 1 Dominique d'Humieres 2012-06-15 20:50:56 UTC
Confirmed with only -Wall.
r176696 is OK,
r177649 gives the segmentation fault.

The backtrace for trunk is


#0  gfc_calculate_transfer_sizes (source=0x142275aa0, mold=0x142276350, size=0x142276110, source_size=0x7fff5fbfce80, result_size=0x7fff5fbfce88, 
    result_length_p=0x0) at /opt/mp/include/gmp.h:1745
#1  0x000000010000fa59 in gfc_check_transfer (source=0x142275aa0, mold=0x142276350, size=0x142276110) at ../../work/gcc/fortran/check.c:4070
#2  0x000000010003a405 in check_specific (specific=0x142829e28, expr=0x1422761d0, error_flag=0) at ../../work/gcc/fortran/intrinsic.c:3916
#3  0x0000000100046f67 in gfc_intrinsic_func_interface (expr=0x1422761d0, error_flag=0) at ../../work/gcc/fortran/intrinsic.c:4132
#4  0x00000001000863fa in gfc_resolve_expr (e=<value optimized out>) at ../../work/gcc/fortran/resolve.c:2335
#5  0x0000000100086d39 in resolve_actual_arglist (arg=<value optimized out>, ptype=<value optimized out>, no_formal_args=<value optimized out>)
    at ../../work/gcc/fortran/resolve.c:1774
#6  0x00000001000874e3 in resolve_call (c=<value optimized out>) at ../../work/gcc/fortran/resolve.c:3691
#7  0x000000010008d66e in resolve_code (code=<value optimized out>, ns=<value optimized out>) at ../../work/gcc/fortran/resolve.c:9533
#8  0x000000010008d1ec in gfc_resolve_blocks (b=<value optimized out>, ns=<value optimized out>) at ../../work/gcc/fortran/resolve.c:9103
#9  0x000000010008d366 in resolve_code (code=<value optimized out>, ns=<value optimized out>) at ../../work/gcc/fortran/resolve.c:9372
#10 0x000000010008d1ec in gfc_resolve_blocks (b=<value optimized out>, ns=<value optimized out>) at ../../work/gcc/fortran/resolve.c:9103
#11 0x000000010008d366 in resolve_code (code=<value optimized out>, ns=<value optimized out>) at ../../work/gcc/fortran/resolve.c:9372
#12 0x000000010008fc84 in resolve_codes (ns=<value optimized out>) at ../../work/gcc/fortran/resolve.c:14044
#13 0x000000010007f868 in gfc_resolve (ns=<value optimized out>) at ../../work/gcc/fortran/resolve.c:14071
#14 0x000000010007514b in gfc_parse_file () at ../../work/gcc/fortran/parse.c:4387
#15 0x00000001000b4216 in gfc_be_parse_file () at ../../work/gcc/fortran/f95-lang.c:191
#16 0x000000010072ada1 in toplev_main (argc=3, argv=0x7fff5fbfd750) at ../../work/gcc/toplev.c:550
#17 0x00000001000018c4 in start ()
Comment 2 Dominique d'Humieres 2012-06-15 21:23:42 UTC
Reduced test case

       SUBROUTINE CGBRFSX(N, RWORK)
       INTEGER N
       REAL RWORK(*)
       REAL ZERO
       PARAMETER (ZERO = 0.0E+0)
       call foo(TRANSFER (RWORK(1:2*N), (/ (ZERO, ZERO) /), N))
       end

It yields a segmentation fault when compiled with -Wsurprising.
Comment 3 Tobias Burnus 2012-06-16 06:15:39 UTC
(In reply to comment #2)
> It yields a segmentation fault when compiled with -Wsurprising.

Hence, the workaround is to compile with -Wno-surprising.


Untested draft patch:

--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -3997,3 +3996,6 @@ gfc_calculate_transfer_sizes (gfc_expr *source, gfc_expr *mold, gfc_expr *size,
 
-    /* Calculate the size of the source.  */
+  if (size && size->expr_type != EXPR_CONSTANT)
+    return FAILURE;
+
+  /* Calculate the size of the source.  */
   if (source->expr_type == EXPR_ARRAY
Comment 4 Tobias Burnus 2012-06-17 19:30:46 UTC
Author: burnus
Date: Sun Jun 17 19:30:29 2012
New Revision: 188708

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188708
Log:
2012-06-17  Tobias Burnus  <burnus@net-b.de>

        PR fortran/53691
        PR fortran/53685
        * check.c (gfc_calculate_transfer_sizes): Return if
        SIZE= is not constant or source-size cannot be determined.

2012-06-17  Tobias Burnus  <burnus@net-b.de>

        PR fortran/53691
        PR fortran/53685
        * gfortran.dg/transfer_check_3.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/transfer_check_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Tobias Burnus 2012-06-22 10:28:01 UTC
Author: burnus
Date: Fri Jun 22 10:27:56 2012
New Revision: 188882

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188882
Log:
2012-06-22  Tobias Burnus  <burnus@net-b.de>

        Backport from mainline
        2012-06-17  Tobias Burnus  <burnus@net-b.de>

        PR fortran/53691
        PR fortran/53685
        * check.c (gfc_calculate_transfer_sizes): Return if
        SIZE= is not constant or source-size cannot be determined.

2012-06-22  Tobias Burnus  <burnus@net-b.de>

        Backport from mainline
        2012-06-17  Tobias Burnus  <burnus@net-b.de>

        PR fortran/53691
        PR fortran/53685
        * gfortran.dg/transfer_check_3.f90: New.


Added:
    branches/gcc-4_7-branch/gcc/testsuite/gfortran.dg/transfer_check_3.f90
Modified:
    branches/gcc-4_7-branch/gcc/fortran/ChangeLog
    branches/gcc-4_7-branch/gcc/fortran/check.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Comment 6 Tobias Burnus 2012-06-22 10:29:05 UTC
FIXED on the 4.7 branch (for 4.7.2) and on the trunk (for 4.8).

Thanks for the bug report and sorry for the breakage!