This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/46974] ICE with TRANSFER using a C_PTR entity
- From: "sgk at troutmask dot apl.washington.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 18 Dec 2010 00:01:18 +0000
- Subject: [Bug fortran/46974] ICE with TRANSFER using a C_PTR entity
- Auto-submitted: auto-generated
- References: <bug-46974-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46974
--- Comment #2 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2010-12-18 00:01:03 UTC ---
On Fri, Dec 17, 2010 at 11:15:44PM +0000, kargl at gcc dot gnu.org wrote:
>
> Anyone know why this flag is needed?
>
Well, the answer is to let simplify_transfer_[34].f90
in the testsuite to compile! :-)
Given
program z
use iso_c_binding
type(c_ptr) m
m = transfer(32512, m)
m = transfer(32512, C_NULL_PTR)
end program z
This patch compiles the above.
Index: simplify.c
===================================================================
--- simplify.c (revision 167949)
+++ simplify.c (working copy)
@@ -5954,6 +5954,11 @@ gfc_simplify_transfer (gfc_expr *source,
if (source->expr_type == EXPR_FUNCTION)
return NULL;
+ if ((mold->expr_type == EXPR_VARIABLE || mold->expr_type == EXPR_STRUCTURE)
+ && mold->ts.type == BT_DERIVED && mold->ts.u.derived
+ && strcmp(mold->ts.u.derived->name, "c_ptr") == 0)
+ return NULL;
+
/* Calculate the size of the source. */
if (source->expr_type == EXPR_ARRAY
&& gfc_array_size (source, &tmp) == FAILURE)
The tree dump looks like
z ()
--More--(74%){
void * m;
{
void * transfer.0;
integer(kind=8) D.1524;
integer(kind=8) D.1523;
static integer(kind=4) C.1522 = 32512;
integer(kind=8) D.1521;
D.1521 = 4;
D.1523 = 8;
__builtin_memcpy ((void *) &transfer.0, (void *) &C.1522,
MAX_EXPR <MIN_EXPR <D.1523, D.1521>, 0>);
m = transfer.0;
}
{
void * transfer.1;
integer(kind=8) D.1530;
integer(kind=8) D.1529;
static void * C.1528 = 0B;
static integer(kind=4) C.1527 = 32512;
integer(kind=8) D.1526;
D.1526 = 4;
D.1529 = 8;
__builtin_memcpy ((void *) &transfer.1, (void *) &C.1527,
MAX_EXPR <MIN_EXPR <D.1529, D.1526>, 0>);
m = transfer.1;
}
}
So we are assigning a void * pointer to a void * pointer. Not
sure this is the desired result.