This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug fortran/34500] New: Bind(C): Character returning function with ENTRY gives ICE


Test case:

function test() bind(C)
  use iso_c_binding
  implicit none
  character(len=1,kind=c_char) :: test, bar
entry bar() bind(C)
end function test

ICE occurs if either test() or bar() or both are bind(c).

The ENTRY fix needs to go into build_entry_thunks:
      if (thunk_sym->attr.function)
        {
          if (gfc_return_by_reference (ns->proc_name))
            {
This branch is entered as the master function,  proc_name, is is_bind_c ==
false, but it fails currently if (thunk_sym->attr.is_bind_c &&
thunk_sym->ts.type == BT_CHARACTER).

The proper tree should looks more or less as follows:

test2 ()
{
  character(kind=1) tmp[1:1];
  integer(kind=4) len;
  master.0.test2 (0, &tmp, len);
  return tmp[1];

That is test() itself returns a scalar character, but master.0.test2 takes the
string as argument, which allows to combine bind(C) with non-bind(C) functions
and allows for different string lengths of ENTRY and function (cf. PR 34421).


-- 
           Summary: Bind(C): Character returning function with ENTRY gives
                    ICE
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org
OtherBugsDependingO 32630
             nThis:


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34500


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