User account creation filtered due to spam.

Bug 71935 - [5/6/7/8 Regression] ICE is_c_interoperable(): gfc_simplify_expr failed
Summary: [5/6/7/8 Regression] ICE is_c_interoperable(): gfc_simplify_expr failed
Status: REOPENED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.0
: P4 normal
Target Milestone: 7.2
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2016-07-19 19:11 UTC by Gerhard Steinmetz
Modified: 2017-05-02 15:58 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-07-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard Steinmetz 2016-07-19 19:11:35 UTC
With an out of bounds error :   (no ICE with 4.8.3)


$ cat z1.f90
program p
   use iso_c_binding
   character(len=1, kind=c_char), parameter :: z(2) = 'z'
   print *, sizeof(z(3))
   print *, c_sizeof(z(3))
end


$ cat z2.f90
program p
   use iso_c_binding
   character(len=1), parameter :: z(2) = 'z'
   print *, sizeof(z(3))
   print *, c_sizeof(z(3))
end



$ gfortran-7-20160717 z1.f90
z1.f90:4:21:

    print *, sizeof(z(3))
                     1
Warning: Array reference at (1) is out of bounds (3 > 2) in dimension 1
z1.f90:5:23:

    print *, c_sizeof(z(3))
                       1
Warning: Array reference at (1) is out of bounds (3 > 2) in dimension 1
z1.f90:5:23:

    print *, c_sizeof(z(3))
                       1
Error: Index in dimension 1 is out of bounds at (1)
f951: internal compiler error: is_c_interoperable(): gfc_simplify_expr failed
0x684721 gfc_internal_error(char const*, ...)
        ../../gcc/fortran/error.c:1312
0x65e848 is_c_interoperable
        ../../gcc/fortran/check.c:4282
0x663846 gfc_check_c_sizeof(gfc_expr*)
        ../../gcc/fortran/check.c:4329
0x695624 check_specific
        ../../gcc/fortran/intrinsic.c:4274
0x69ea04 gfc_intrinsic_func_interface(gfc_expr*, int)
        ../../gcc/fortran/intrinsic.c:4489
0x6e42c6 resolve_unknown_f
        ../../gcc/fortran/resolve.c:2718
0x6e42c6 resolve_function
        ../../gcc/fortran/resolve.c:3020
0x6e42c6 gfc_resolve_expr(gfc_expr*)
        ../../gcc/fortran/resolve.c:6353
0x6e8ef1 gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.c:10469
0x6e8c4b gfc_resolve_blocks(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.c:9520
0x6e8ffe gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc/fortran/resolve.c:10459
0x6eb6d2 resolve_codes
        ../../gcc/fortran/resolve.c:15667
0x6eb7c1 gfc_resolve(gfc_namespace*)
        ../../gcc/fortran/resolve.c:15701
0x6d6aea resolve_all_program_units
        ../../gcc/fortran/parse.c:5855
0x6d6aea gfc_parse_file()
        ../../gcc/fortran/parse.c:6107
0x719192 gfc_be_parse_file
        ../../gcc/fortran/f95-lang.c:198
Comment 1 Martin Liška 2016-07-19 20:12:06 UTC
Confirmed, started with GCC 4.9.0.
Comment 2 kargl 2016-07-19 21:50:09 UTC
Index: check.c
===================================================================
--- check.c	(revision 238385)
+++ check.c	(working copy)
@@ -4278,7 +4278,7 @@ is_c_interoperable (gfc_expr *expr, cons
       }
 
     if (expr->ts.u.cl && expr->ts.u.cl->length
-	&& !gfc_simplify_expr (expr, 0))
+	&& !gfc_simplify_expr (expr->ts.u.cl->length, 0))
       gfc_internal_error ("is_c_interoperable(): gfc_simplify_expr failed");
 
     if (!c_loc && expr->ts.u.cl


Weird that an array reference out-of-bounds is only an error.
Comment 3 Dominique d'Humieres 2016-07-19 21:58:38 UTC
Likely r197053.
Comment 4 kargl 2016-07-22 18:53:42 UTC
Author: kargl
Date: Fri Jul 22 18:53:11 2016
New Revision: 238665

URL: https://gcc.gnu.org/viewcvs?rev=238665&root=gcc&view=rev
Log:
2016-07-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/71935
	* check.c (is_c_interoperable): Simplify right expression. 

2016-07-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/71935
	* gfortran.dg/c_sizeof_1.f90: Move invalid code to ...
	* gfortran.dg/c_sizeof_6.f90: here.  Test for error.
	* gfortran.dg/pr71935.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/c_sizeof_6.f90
    trunk/gcc/testsuite/gfortran.dg/pr71935.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/c_sizeof_1.f90
Comment 5 kargl 2016-07-22 18:56:27 UTC
fixed.
Comment 6 kargl 2016-07-23 14:11:24 UTC
Seems to be some discussion with not quite well-defined
language in the standard.

https://groups.google.com/forum/#!topic/comp.lang.fortran/f2wGjmaLXPU
Comment 7 Jakub Jelinek 2017-05-02 15:58:49 UTC
GCC 7.1 has been released.