User account creation filtered due to spam.

Bug 57048 - [5/6/7/8 Regression] Handling of C_PTR and C_FUNPTR leads to reject valid
Summary: [5/6/7/8 Regression] Handling of C_PTR and C_FUNPTR leads to reject valid
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.9.0
: P4 normal
Target Milestone: 5.5
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2013-04-23 13:02 UTC by Tobias Burnus
Modified: 2016-08-03 11:02 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-11-23 00:00:00


Attachments
Bigger patch (doesn't work better :-/ ) (1.34 KB, patch)
2014-01-26 17:23 UTC, Mikael Morin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2013-04-23 13:02:26 UTC
Reported by Angelo Graziosi at http://gcc.gnu.org/ml/fortran/2013-04/msg00210.html

Using in file1:
  module m
  ...
    type t
      type(c_funptr) :: funptr
    end type

and in file2:
   use iso_c_binding, ONLY: c_funloc
   use m
   type(t) :: x
   ...
   x%funptr = c_funloc(proc)

fails with:
  Error: Can't convert TYPE(c_funptr) to INTEGER(4) at (1)


The problem is that the .mod file only contains:
  win32_types.mod:5 'C_funptr' '__iso_c_binding' '' 1 ((DERIVED UNKNOWN-INTENT
while the symtree is searched for "c_funptr".

Workaround: Editing the .mod file and changing C_funptr to c_funptr.
Comment 1 Dominique d'Humieres 2013-11-23 13:33:06 UTC
On x86_64-apple-darwin13, I get with gfortran 4.8.2

[Book15] f90/bug% gfortran pr57048.f90
[Book15] f90/bug% grep funptr m.mod
(('c_funptr' '__iso_c_binding' 2) ('t' 'm' 3))
(2 'C_funptr' '__iso_c_binding' '' 1 ((DERIVED UNKNOWN-INTENT
DERIVED 2 0 1 1 UNKNOWN ()) 0 0 () () 0 ((4 '__c_funptr_c_address' (
(UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 ((5 'funptr' (DERIVED 2 0 0 0
7 'c_funptr' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
('C_funptr' 0 2 'T' 0 3 '__iso_c_binding' 0 6 'c_funptr' 0 7 'm' 0 8 't'

What is setting the capital C and why?
Comment 2 Mikael Morin 2014-01-26 17:21:11 UTC
This fixes this case;
However, it is not free of regressions.

diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index adc34dd..24ceaea 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -2366,8 +2366,6 @@ gfc_get_derived_type (gfc_symbol * derived)
       else
        derived->backend_decl = pfunc_type_node;
 
-      derived->ts.kind = gfc_index_integer_kind;
-      derived->ts.type = BT_INTEGER;
       /* Set the f90_type to BT_VOID as a way to recognize something of type
          BT_INTEGER that needs to fit a void * for the purpose of the
          iso_c_binding derived types.  */
Comment 3 Mikael Morin 2014-01-26 17:23:45 UTC
Created attachment 31956 [details]
Bigger patch (doesn't work better :-/ )

And this is how far I got before giving up.
Comment 4 Jakub Jelinek 2014-04-22 11:36:55 UTC
GCC 4.9.0 has been released
Comment 5 Jakub Jelinek 2014-07-16 13:30:18 UTC
GCC 4.9.1 has been released.
Comment 6 Jakub Jelinek 2014-10-30 10:40:23 UTC
GCC 4.9.2 has been released.
Comment 7 Jakub Jelinek 2015-06-26 19:57:48 UTC
GCC 4.9.3 has been released.
Comment 8 Richard Biener 2016-08-03 11:00:09 UTC
GCC 4.9 branch is being closed