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

--- Comment #13 from rguenther at suse dot de <rguenther at suse dot de> ---
On Mon, 14 Jul 2014, fxcoudert at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41227
> 
> --- Comment #12 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> 
> ---
> I disagree with Tobias' reading: it seems to me that the single-variable 
> common
> block should be interoperable with both the single-common C struct and C
> variable.
> 
> The Intel compiler makes both cases work:
> 
> [fx@kelvin tmp]$ cat a.f90 
> program test
>   use iso_c_binding
>   integer(c_int) :: i
>   common /a/ i
>   bind(c) :: /a/
> 
>   interface
>     subroutine foo() bind(c)
>     end subroutine
>   end interface
> 
>   i = 42
>   print *, i
>   call foo()
>   print *, i
> end program test
> [fx@kelvin tmp]$ cat a1.c 
> extern int a;
> void foo (void) { a = -1; }
> [fx@kelvin tmp]$ cat a2.c 
> extern struct { int i; } a;
> void foo (void) { a.i = -1; }
> [fx@kelvin tmp]$ icc -c a1.c && ifort a.f90 a1.o && ./a.out
>           42
>           -1
> [fx@kelvin tmp]$ icc -c a2.c && ifort a.f90 a2.o && ./a.out
>           42
>           -1
> 
> 
> I believe we should do so too. And if I understand correctly what Richard 
> said,
> this means relaxing the LTO type rules, is that right?

Yes (to get rid of the warning and to avoid eventual wrong-code bugs).

Does it need to inter-operate with

extern struct { struct { int i; } a; } a;

?  Or

extern union { int i; } a;

?

Reply via email to