mixing gfortran and g++ on Cygwin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Regarding GCC v4.0.2 built using gcc v3.4.4 on Cygwin over Windows XP.

I have a program that mixes C++ and Fortran code.  It does I/O in both
langauges.  This works in GCC v4.0.2 on Linux (SuSE 9.3), but on Cygwin
it doesn't.  I get a segfault in the gfortran io code.  Here's what gdb
has to say:

Program received signal SIGSEGV, Segmentation fault.
0x610c4a7b in memset () from /usr/bin/cygwin1.dll
(gdb) where
#0  0x610c4a7b in memset () from /usr/bin/cygwin1.dll
#1 0x004097b8 in write_integer (source=0x20 <Address 0x20 out of bounds>, length=2)
    at ../../../gcc-4.0.2-src/libgfortran/io/write.c:1194
#2 0x00409aa5 in *__gfortrani_list_formatted_write (type=BT_INTEGER, p=0x22eee4, len=4)
    at ../../../gcc-4.0.2-src/libgfortran/io/write.c:1340
#3  0x00402002 in *__gfortran_transfer_integer (p=0x22eee4, kind=4)
    at ../../../gcc-4.0.2-src/libgfortran/io/transfer.c:851
#4  0x00401242 in fort_ioroutine_ (int1=@0x22eee4) at testfort.f:9
#5  0x004010d4 in main () at testcerr.cpp:9

I link with g++ and -lgfortran

Does anyone have any ideas how I could work around this?
Is there a gfortran RTL routine I can call to initialize
the IO data structures or something?

I know this is vague.  I'll gladly provide more details if requested.

Thanks,
david

Here's some code that demonstrates the problem:

// file: testc.cpp
/////////////////////////////
extern "C" {
void fort_ioroutine_( int * a );
}
int main(){
  int i = 23 ;
  fort_ioroutine_(&i) ;
}

!! file: testf.f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      subroutine fort_ioroutine( int1 )
      integer int1 ,unit ,status
      unit = 19
      open( unit ,file='IOtest.dat' ,iostat=status )
      if( status .NE. 0 )then
        write(*,*) 'error: open failed, status = ',status
        return
      endif
      write( unit,*,iostat=status ) int1 ,'is the integer.'
      return
      end


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux