[Bug fortran/28818] New: C/Fortran interoperability: variable number of arguments passed from fortran to C causes Illegal instruction

cyan+gcc at compsoc dot nuigalway dot ie gcc-bugzilla@gcc.gnu.org
Wed Aug 23 11:38:00 GMT 2006


With svn revision 116324, on x86_64-unknown-linux-gnu:

[pfarrell@alexander:~]$ cat test.c
#include <stdio.h>
#include <stdarg.h>

void test_(int *test, ...)
{
    printf("test: %d\n", *test);
    return;
}
[pfarrell@alexander:~]$ cat forttest.F90
program test_printf

    call test(-1, 'd')
    call test(-1, 'd')

end program test_printf
[pfarrell@alexander:~]$ make
gcc -c -o test.o test.c
gfortran -c -o forttest.o forttest.F90
gfortran -o test test.o forttest.o
[pfarrell@alexander:~]$ ./test
test: -1
Illegal instruction
[pfarrell@alexander:~]$

This does not happen if

void test_(int *test, ...)

is replaced with

void test_(int *test, char *d)

so it appears there's something wrong with variable numbers of arguments being
passed between fortran and C.

Here's what gdb says:

Breakpoint 1, test_ (test=0x400878) at test.c:6
6           printf("test: %d\n", *test);
(gdb) n
test: -1
8       }
(gdb) nexti
0x000000000040070e in test_ (test=0x400874) at test.c:8
8       }
(gdb) nexti
MAIN__ () at forttest.F90:4
4           call test(-1, 'd')
Current language:  auto; currently fortran
(gdb) nexti
0x0000000000400741      4           call test(-1, 'd')
(gdb) nexti
0x0000000000400746      4           call test(-1, 'd')
(gdb) nexti
0x000000000040074b      4           call test(-1, 'd')
(gdb) nexti

Program received signal SIGILL, Illegal instruction.
0x00000000004006ca in test_ (test=0x400878) at test.c:5
5       {
Current language:  auto; currently c
(gdb)

but I don't know enough about assembly to help any more.


-- 
           Summary: C/Fortran interoperability: variable number of arguments
                    passed from fortran to C causes Illegal instruction
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cyan+gcc at compsoc dot nuigalway dot ie
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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



More information about the Gcc-bugs mailing list