Bug 84511 - [6/7/8 Regression] Internal compiler error from directly printing return of C_LOC
Summary: [6/7/8 Regression] Internal compiler error from directly printing return of C...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.2.0
: P4 normal
Target Milestone: 6.5
Assignee: kargls
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-02-22 11:25 UTC by h.ratcliffe
Modified: 2018-02-23 19:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.5
Known to fail: 4.9.3, 5.5.0, 6.4.0, 7.3.0, 8.0
Last reconfirmed: 2018-02-22 00:00:00


Attachments
Tarball of 2-file working example (662 bytes, application/gzip)
2018-02-22 11:25 UTC, h.ratcliffe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description h.ratcliffe 2018-02-22 11:25:15 UTC
Created attachment 43487 [details]
Tarball of 2-file working example

Directly printing return from C_LOC causes an internal compiler error if C_LOC is called on a type defined in a module in a separate file. Capturing the return and then printing succeeds. 
Full error report is

f951: internal compiler error: Bad IO basetype (10)
0x5cbd3f gfc_internal_error(char const*, ...)
	../../src/gcc/fortran/error.c:1348
0x6bd3fe transfer_expr
	../../src/gcc/fortran/trans-io.c:2475
0x6c0748 gfc_trans_transfer(gfc_code*)
	../../src/gcc/fortran/trans-io.c:2620
0x6697a7 trans_code
	../../src/gcc/fortran/trans.c:2017
0x6be1d6 build_dt
	../../src/gcc/fortran/trans-io.c:2028
0x669787 trans_code
	../../src/gcc/fortran/trans.c:1989
0x68e887 gfc_generate_function_code(gfc_namespace*)
	../../src/gcc/fortran/trans-decl.c:6332
0x66d1f9 gfc_generate_module_code(gfc_namespace*)
	../../src/gcc/fortran/trans.c:2195
0x622f3b translate_all_program_units
	../../src/gcc/fortran/parse.c:6061
0x622f3b gfc_parse_file()
	../../src/gcc/fortran/parse.c:6274
0x66600f gfc_be_parse_file
	../../src/gcc/fortran/f95-lang.c:204


Same error arises on gfortran 5.4 and 7.2.0 on Ubuntu and 6.3.0 on OSX, but 4.3.4 on SLES 11 (SP4) succeeds. 

The error does not occur if module TWO defining the type is in the file where C_LOC is called.
Comment 1 Dominique d'Humieres 2018-02-22 12:09:17 UTC
Confirmed from 4.9.3 up to trunk (8.0). The test compiles with 4.8.5.
Comment 2 kargls 2018-02-22 19:18:00 UTC
I have a patch.
Comment 3 kargls 2018-02-23 19:00:19 UTC
Author: kargl
Date: Fri Feb 23 18:59:38 2018
New Revision: 257943

URL: https://gcc.gnu.org/viewcvs?rev=257943&root=gcc&view=rev
Log:
2018-02-23  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/84511
	* trans-io.c (transfer_expr): Deal with C_LOC in transfer statement.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-io.c
Comment 4 kargls 2018-02-23 19:38:29 UTC
Author: kargl
Date: Fri Feb 23 19:37:57 2018
New Revision: 257948

URL: https://gcc.gnu.org/viewcvs?rev=257948&root=gcc&view=rev
Log:
2018-02-23  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/84511
	* trans-io.c (transfer_expr): Deal with C_LOC in transfer statement.

Modified:
    branches/gcc-7-branch/gcc/fortran/ChangeLog
    branches/gcc-7-branch/gcc/fortran/trans-io.c
Comment 5 kargls 2018-02-23 19:43:15 UTC
Author: kargl
Date: Fri Feb 23 19:42:43 2018
New Revision: 257950

URL: https://gcc.gnu.org/viewcvs?rev=257950&root=gcc&view=rev
Log:
2018-02-23  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/84511
	* trans-io.c (transfer_expr): Deal with C_LOC in transfer statement.

Modified:
    branches/gcc-6-branch/gcc/fortran/ChangeLog
    branches/gcc-6-branch/gcc/fortran/trans-io.c
Comment 6 kargls 2018-02-23 19:44:35 UTC
Fixed on 6-branch, 7-branch, and trunk.
Thanks for the bug report.