public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/66238] New: C/Fortran interoperability broken with -flto
@ 2015-05-21 10:13 dominiq at lps dot ens.fr
  2015-05-21 13:28 ` [Bug fortran/66238] " mikael at gcc dot gnu.org
  2015-09-06  1:13 ` dominiq at lps dot ens.fr
  0 siblings, 2 replies; 3+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-05-21 10:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66238

            Bug ID: 66238
           Summary: C/Fortran interoperability broken with -flto
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dominiq at lps dot ens.fr
                CC: hubicka at gcc dot gnu.org
  Target Milestone: ---

When running the gfortran test suite with -flto, I get the following new
failures since r223288

FAIL: gfortran.dg/bind_c_usage_16.f03   -g -flto  (test for excess errors)
FAIL: gfortran.dg/bind_c_usage_17.f90   -g -flto  (test for excess errors)
FAIL: gfortran.dg/c_char_tests.f03   -g -flto  (test for excess errors)
FAIL: gfortran.dg/proc_ptr_7.f90   -g -flto  (test for excess errors)

The errors are

/opt/gcc/_clean/gcc/testsuite/gfortran.dg/bind_c_usage_16_c.c:8:6: warning:
type of 'returnA' does not match original declaration [-Wlto-type-mismatch]
 char returnA(char *);
      ^
lto1: note: return value type mismatch
lto1: note: type 'unsigned char' should match type 'char'
/opt/gcc/_clean/gcc/testsuite/gfortran.dg/bind_c_usage_16.f03:12:0: note: 'bar'
was previously declared here
   function bar(x)  bind(c, name="returnA")
^
/opt/gcc/_clean/gcc/testsuite/gfortran.dg/bind_c_usage_16_c.c:9:6: warning:
type of 'returnB' does not match original declaration [-Wlto-type-mismatch]
 char returnB(void);
      ^
lto1: note: return value type mismatch
lto1: note: type 'unsigned char' should match type 'char'
/opt/gcc/_clean/gcc/testsuite/gfortran.dg/bind_c_usage_16.f03:17:0: note: 'foo'
was previously declared here
   function foo()  bind(c, name="returnB")
^

/opt/gcc/_clean/gcc/testsuite/gfortran.dg/bind_c_usage_17.f90:24:0: warning:
type of 'cdir' does not match original declaration [-Wlto-type-mismatch]
   str1 = cdir()
^
lto1: note: return value type mismatch
lto1: note: type 'char' should match type 'unsigned char'
/opt/gcc/_clean/gcc/testsuite/gfortran.dg/bind_c_usage_17_c.c:4:6: note: 'cdir'
was previously declared here
 char cdir(void){return '/';}
      ^

/opt/gcc/_clean/gcc/testsuite/gfortran.dg/c_char_driver.c:1:6: warning: type of
'param_test' does not match original declaration [-Wlto-type-mismatch]
 void param_test(char my_char, char my_char_2);
      ^
lto1: note: type mismatch in parameter 1
/opt/gcc/_clean/gcc/testsuite/gfortran.dg/c_char_tests.f03:10:0: note:
'param_test' was previously declared here
   subroutine param_test(my_char, my_char_2) bind(c)
^

and

/opt/gcc/_clean/gcc/testsuite/gfortran.dg/proc_ptr_7.f90:22:0: warning: type of
'assignf' does not match original declaration [-Wlto-type-mismatch]
   call assignF(ptr)
^
lto1: note: type mismatch in parameter 1
/opt/gcc/_clean/gcc/testsuite/gfortran.dg/proc_ptr_7.c:8:6: note: 'assignf_'
was previously declared here
 void assignf_(int(**ptr)(void)) {
      ^

The first two failures can be fixed by replacing 'char' with 'unsigned char' in
the C files. I don't know how to fix the two other ones.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug fortran/66238] C/Fortran interoperability broken with -flto
  2015-05-21 10:13 [Bug fortran/66238] New: C/Fortran interoperability broken with -flto dominiq at lps dot ens.fr
@ 2015-05-21 13:28 ` mikael at gcc dot gnu.org
  2015-09-06  1:13 ` dominiq at lps dot ens.fr
  1 sibling, 0 replies; 3+ messages in thread
From: mikael at gcc dot gnu.org @ 2015-05-21 13:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66238

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #1 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Dominique d'Humieres from comment #0)
> When running the gfortran test suite with -flto, I get the following new
> failures since r223288
> 
I don't have updated to that revision, so that I can't check by myself, but
here are a few possible problems:

For proc_ptr_7, the procedure pointer argument has a variadic number of
arguments on the fortran side, and no argument on the C side.

For c_char_tests, a possible problem is the declaration of arguments as
  character(c_char), value :: foo
This declares a character of len c_char and default kind as far as I know.
According to
https://gcc.gnu.org/onlinedocs/gfortran/Interoperable-Subroutines-and-Functions.html
the canonical declaration is rather:
  character(kind=c_char) :: foo(*)
With the value attribute, I don't know how it should be handled though.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug fortran/66238] C/Fortran interoperability broken with -flto
  2015-05-21 10:13 [Bug fortran/66238] New: C/Fortran interoperability broken with -flto dominiq at lps dot ens.fr
  2015-05-21 13:28 ` [Bug fortran/66238] " mikael at gcc dot gnu.org
@ 2015-09-06  1:13 ` dominiq at lps dot ens.fr
  1 sibling, 0 replies; 3+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-09-06  1:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66238

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-09-06
     Ever confirmed|0                           |1

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The two first tests are fixed with the patch

[Book15] gcc/work% diff -up
../_clean/gcc/testsuite/gfortran.dg/bind_c_usage_16_c.c
gcc/testsuite/gfortran.dg/bind_c_usage_16_c.c
--- ../_clean/gcc/testsuite/gfortran.dg/bind_c_usage_16_c.c     2009-11-25
18:17:40.000000000 +0100
+++ gcc/testsuite/gfortran.dg/bind_c_usage_16_c.c       2015-09-05
22:17:49.000000000 +0200
@@ -5,13 +5,13 @@

 #include <stdlib.h>

-char returnA(char *);
-char returnB(void);
+unsigned char returnA(unsigned char *);
+unsigned char returnB(void);
 void test(void);

 int main()
 {
-  char c;
+  unsigned char c;
   c = 'z';
   c = returnA(&c);
   if (c != 'A') abort();
[Book15] gcc/work% diff -up
../_clean/gcc/testsuite/gfortran.dg/bind_c_usage_17_c.c
gcc/testsuite/gfortran.dg/bind_c_usage_17_c.c
--- ../_clean/gcc/testsuite/gfortran.dg/bind_c_usage_17_c.c     2009-11-25
18:17:47.000000000 +0100
+++ gcc/testsuite/gfortran.dg/bind_c_usage_17_c.c       2015-09-05
22:19:22.000000000 +0200
@@ -1,4 +1,4 @@
 /* PR fortran/37201.
    Linked with bind_c_usage_17.f90.  */

-char cdir(void){return '/';}
+unsigned char cdir(void){return '/';}

> For c_char_tests, a possible problem is the declaration of arguments as
>   character(c_char), value :: foo
> This declares a character of len c_char and default kind as far as I know.
> According to
> https://gcc.gnu.org/onlinedocs/gfortran/Interoperable-Subroutines-and-Functions.html
> the canonical declaration is rather:
>  character(kind=c_char) :: foo(*)
> With the value attribute, I don't know how it should be handled though.

Either I don't understand this or it is not working.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-06  1:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-21 10:13 [Bug fortran/66238] New: C/Fortran interoperability broken with -flto dominiq at lps dot ens.fr
2015-05-21 13:28 ` [Bug fortran/66238] " mikael at gcc dot gnu.org
2015-09-06  1:13 ` dominiq at lps dot ens.fr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).