This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Internal compiler error


Yay! I found the problem. There was a place where I was calling the wrong function:

-     tmp = gfc_allocate_using_lib (&set_status_block, size, status);
+     tmp = gfc_allocate_using_malloc (&set_status_block, size, status);


So of course the compiler would fail. The coarray lib is not even compiled by default.


Ok, back to work...

Cheers,
Daniel.


On 07/09/2011 09:01 PM, Daniel Carrera wrote:
Hello,

Does anyone have any tips for how to trace an internal compiler error?

I am making a patch that involves changing function parameters and
clearly I've made some mistake in building the GIMPLE tree, but I'm
having a hard time figuring out where it is.

Currently SVN has something like this:

stat = gfc_create_var (gfc_int4_type_node, "stat");
pstat = gfc_build_addr_expr (NULL_TREE, stat);
...
gfc_allocate_allocatable (... pstat);


It turns out that the pointer is not needed, so I am changing the above to this:

stat = gfc_create_var (gfc_int4_type_node, "stat");
...
gfc_allocate_allocatable (... stat);


I thought I had made all the correct changes inside the allocate function. For example:


1) The line:


tree status_type = status ? TREE_TYPE( TREE_TYPE (status)) : NULL_TREE;

Becomes:

tree status_type = status ? TREE_TYPE (status) : NULL_TREE;


2) The line:


on_error = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
fold_build1_loc (input_location, INDIRECT_REF,
status_type, status),
build_int_cst (status_type, LIBERROR_ALLOCATION));


Becomes:


on_error = fold_build2_loc (input_location, MODIFY_EXPR, status_type,
status,
build_int_cst (status_type, LIBERROR_ALLOCATION));


And I think those are mainly the changes. Btw, for completeness my current non-functioning patch is attached and a very simple program that gives a segfault is below:

program main

implicit none

real,allocatable :: mol
integer :: i

! allocate (mol) ! This works.
allocate (mol, stat=i) ! This fails.

end program main


Cheers, Daniel.


--
I'm not overweight, I'm undertall.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]