This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/33760] New: Bind(C): Using C_PTR as structure constructor gives an ICE
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Oct 2007 11:04:57 -0000
- Subject: [Bug fortran/33760] New: Bind(C): Using C_PTR as structure constructor gives an ICE
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gfortran crashes if one uses
cptr = C_PTR(p+1)
Here, C_PTR is a structure constructor; this usage is invalid Fortran 2003 (as
type(C_PTR) has PRIVATE components according to the Fortran 2003 standard); NAG
f95 therefore diagnoses:
Error: Components of structure constructor 'c_ptr' at (1) are PRIVATE
gfortran allows currently to access the private components to allow to print
the pointer address as in
print *, cptr
(For -std=f2003, this gives the expected error because of the private
components. However, for C_PTR(..) -std=f2003 does not help.)
Valgrind:
==15961== Invalid read of size 8
==15961== at 0x49F466: gfc_conv_expr (trans-expr.c:3316)
==15961== by 0x49FB9C: gfc_trans_assignment_1 (trans-expr.c:4075)
==15961== by 0x49FDAC: gfc_trans_assignment (trans-expr.c:4222)
==15961== by 0x482E67: gfc_trans_code (trans.c:993)
==15961== by 0x498669: gfc_generate_function_code (trans-decl.c:3307)
==15961== by 0x45462B: gfc_parse_file (parse.c:3384)
Test program, found at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/0ea1d42c43b6d54a/
program main
use ISO_C_BINDING
implicit none
integer(C_INTPTR_T) p
type(C_PTR) cptr
p = 0
cptr = C_PTR(p+1)
end program main
--
Summary: Bind(C): Using C_PTR as structure constructor gives an
ICE
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: ice-on-invalid-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: burnus at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33760