Bug 36703 - ICE (segfault) in reduce_binary0 (arith.c:1778)
Summary: ICE (segfault) in reduce_binary0 (arith.c:1778)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2008-07-02 20:24 UTC by Tobias Burnus
Modified: 2009-04-06 11:07 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-02-13 12:53:35


Attachments
Test case (777 bytes, text/plain)
2008-07-02 20:26 UTC, Tobias Burnus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2008-07-02 20:24:27 UTC
http://groups.google.com/group/comp.lang.fortran/msg/b600c081a3654936
compiling attached program causes a segfault.

$ gfortran -c -fcray-pointer aaa.f90
aaa.f90: In function 'fptr':
aaa.f90:89: internal compiler error: Segmentation fault


==4019== Invalid read of size 4
==4019==    at 0x40327E: reduce_binary0 (arith.c:1778)
==4019==    by 0x40407E: eval_intrinsic_f3 (arith.c:1841)
==4019==    by 0x4AA386: gfc_apply_interface_mapping_to_expr (trans-expr.c:1815)
==4019==    by 0x4B157E: gfc_apply_interface_mapping (trans-expr.c:1991)
==4019==    by 0x4AB839: gfc_conv_function_call (trans-expr.c:2669)
==4019==    by 0x4AC6CB: gfc_conv_function_expr (trans-expr.c:3201)
==4019==    by 0x496DB7: gfc_add_loop_ss_code (trans-array.c:1977)
==4019==    by 0x497980: gfc_conv_loop_setup (trans-array.c:3496)
==4019==    by 0x4BBB6E: gfc_trans_transfer (trans-io.c:2216)
==4019==    by 0x48C5C7: gfc_trans_code (trans.c:1118)
==4019==    by 0x4BEC48: build_dt (trans-io.c:1805)
==4019==    by 0x48C5F7: gfc_trans_code (trans.c:1090)
Comment 1 Tobias Burnus 2008-07-02 20:26:24 UTC
Created attachment 15844 [details]
Test case
Comment 2 Paul Thomas 2009-02-12 09:19:20 UTC
(In reply to comment #1)

Interestingly, if the WRITE statement is cut, the compilation now fails with:

pr36703.f90: In function 'gp':
pr36703.f90:46: internal compiler error: in expand_expr_real_1, at expr.c:7282

This corresponds to the line:
  __result_gp = get_funloc (make_mess, aux, ..__result);

and the declaration of get_funloc is:
get_funloc (void (*<T193>) (character(kind=1)[0:][1:.x] * &, integer(kind=4), st
ruct array01_integer(kind=4) &) x, void (*<T5b>) (void) (*<T181>) (void) y, inte
ger(kind=4) _x)
{
  void (*<T5b>) (void) __result_get_funloc;

  __result_get_funloc = y (x);
  return __result_get_funloc;
}

which looks OK.  The ICE is generated by -
    context = decl_function_context (exp);
    gcc_assert (!context
                || context = current_function_decl
                || TREE_STATIC (exp)
                /* ??? C++ creates functions that are not TREE_STATIC.  */
                || TREE_CODE (exp) == FUNC_DECL);

I have not checked yet but I would guess that it is the latter that is the problem.

Paul
Comment 3 Paul Thomas 2009-02-13 12:53:35 UTC
The patch for 36703 also fixes this fellow.

Paul
Comment 4 Paul Thomas 2009-02-13 21:12:54 UTC
Subject: Bug 36703

Author: pault
Date: Fri Feb 13 21:12:34 2009
New Revision: 144164

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144164
Log:
2009-02-13  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/36703
	PR fortran/36528
	* trans-expr.c (gfc_conv_function_val): Stabilize Cray-pointer
	function references to ensure that a valid expression is used.
	(gfc_conv_function_call): Pass Cray pointers to procedures.

2009-02-13  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/36528
	* gfortran.dg/cray_pointers_8.f90: New test.

	PR fortran/36703
	* gfortran.dg/cray_pointers_9.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/cray_pointers_8.f90
    trunk/gcc/testsuite/gfortran.dg/cray_pointers_9.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 Paul Thomas 2009-03-28 17:08:47 UTC
Subject: Bug 36703

Author: pault
Date: Sat Mar 28 17:08:25 2009
New Revision: 145196

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145196
Log:
2009-02-13  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/36703
	PR fortran/36528
	* trans-expr.c (gfc_conv_function_val): Stabilize Cray-pointer
	function references to ensure that a valid expression is used.
	(gfc_conv_function_call): Pass Cray pointers to procedures.

2009-02-13  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/36528
	* gfortran.dg/cray_pointers_8.f90: New test.

	PR fortran/36703
	* gfortran.dg/cray_pointers_9.f90: New test.

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

Comment 6 Paul Thomas 2009-04-06 11:07:51 UTC
Fixed on trunk and 4.4

Thanks for the report

Paul