public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/23349] New: -m64 gives runtime errors in combined Fortran/C programs
@ 2005-08-12 8:15 georg dot denk at infineon dot com
2005-08-12 12:29 ` [Bug fortran/23349] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: georg dot denk at infineon dot com @ 2005-08-12 8:15 UTC (permalink / raw)
To: gcc-bugs
Combining a Fortran-routine and a C-routine gives a binary, which produces
almost all errors, like illegal instruction, segmention fault, invalid output,
when the switch -m64 is used. The program works fine using -m32 or using -m64
and an older version of GCC or using a Sun compiler.
Example:
---- snip: file test2.F -----
PROGRAM TEST
IMPLICIT NONE
INTEGER wrtmsg
EXTERNAL wrtmsg
INTEGER I, IERROR
I = 1
IERROR = wrtmsg(I,
* 'This is the string %s no. %d: %s.'//CHAR(0),
* 'test1'//CHAR(0), I, 'TEST 1'//CHAR(0))
I = 2
IERROR = wrtmsg(I,
* 'This is the string %s no. %d: %s.'//CHAR(0),
* 'test2'//CHAR(0), I, 'TEST 2'//CHAR(0))
I = 3
IERROR = wrtmsg(I,
* 'This is the %drd string %s no. %d: %s.'//CHAR(0),
* I, 'test3'//CHAR(0), I, 'TEST 3'//CHAR(0))
STOP
END
---- snap ---
---- snip: file wrtmsg.c ----
#include <stdarg.h>
#include <stdio.h>
int
wrtmsg_(int *i, char *format, ...)
{
char tmp_string[1000];
va_list args;
int *i1, *i2;
char *s1, *s2;
va_start(args, format);
if (*i == 1 || *i == 2)
{
s1 = (char *) va_arg(args, char*);
i1 = (int *) va_arg(args, int*);
s2 = (char *) va_arg(args, char*);
snprintf(tmp_string, 1000, format, s1, *i1, s2);
}
else
{
i1 = (int *) va_arg(args, int*);
s1 = (char *) va_arg(args, char*);
i2 = (int *) va_arg(args, int*);
s2 = (char *) va_arg(args, char*);
snprintf(tmp_string, 1000, format, *i1, s1, *i2, s2);
}
va_end(args);
printf("%s\n", tmp_string);
return *i+1;
}
---- snap ----
Compiler used:
% gfortran -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../../gcc-4.0.1/configure --prefix=/tmp2/denk/GCC4.0.1
--exec-prefix=/tmp2/denk/GCC4.0.1/LINUXAMD64 --enable-languages=c,c++,f95,java
--with-gmp=/tmp2/denk/GCC4.0.1/LINUXAMD64 --with-mpfr=/tmp2/denk/GCC4.0.1
Thread model: posix
gcc version 4.0.1
How to reproduce:
% gfortran -c -fno-second-underscore -Wall -m64 -g test2.F
% gcc -c -Wall -m64 -g wrtmsg.c
% gfortran -o test2 -Wall -m64 -g wrtmsg.o test2.o
Results:
% ./test2
This is the string test1 no. 1: TEST 1.
This is the string test2 no. 2: TEST 2.
Illegal instruction
% ./test2
This is the string test1 no. 1: TEST 1.
This is the string test2 no. 2: TEST 2.
Segmentation fault
% ./test2
This is the string test1 no. 1: TEST 1.
This is the string test2 no. 2: TEST 2.
STOP 0
(which means that the last output line has got lost)
--
Summary: -m64 gives runtime errors in combined Fortran/C programs
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: georg dot denk at infineon dot com
CC: gcc-bugs at gcc dot gnu dot org,georg dot denk at
infineon dot com
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=23349
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/23349] -m64 gives runtime errors in combined Fortran/C programs
2005-08-12 8:15 [Bug fortran/23349] New: -m64 gives runtime errors in combined Fortran/C programs georg dot denk at infineon dot com
@ 2005-08-12 12:29 ` pinskia at gcc dot gnu dot org
2005-08-12 12:45 ` georg dot denk at infineon dot com
2005-08-12 22:34 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-12 12:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-12 12:29 -------
I think this is really just invalid. As the ABI for var-args is different from the ABI for non var-args. And
fortran only passes via non var-args functions.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23349
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/23349] -m64 gives runtime errors in combined Fortran/C programs
2005-08-12 8:15 [Bug fortran/23349] New: -m64 gives runtime errors in combined Fortran/C programs georg dot denk at infineon dot com
2005-08-12 12:29 ` [Bug fortran/23349] " pinskia at gcc dot gnu dot org
@ 2005-08-12 12:45 ` georg dot denk at infineon dot com
2005-08-12 22:34 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: georg dot denk at infineon dot com @ 2005-08-12 12:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From georg dot denk at infineon dot com 2005-08-12 12:45 -------
(In reply to comment #1)
> I think this is really just invalid. As the ABI for var-args is different
from the ABI for non var-args. And
> fortran only passes via non var-args functions.
I don't think that this is "just invalid" --- and this is not because we use
this kind of code in our application at many places ;-)
At least it works with older gcc/g77 combination (gcc 3.4.3 does it right with
-m64), also the Sun Compiler with -xarch=v9a and the Intel Itanium compiler. So
it is at least a regression compared to gcc 3.4.3.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23349
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/23349] -m64 gives runtime errors in combined Fortran/C programs
2005-08-12 8:15 [Bug fortran/23349] New: -m64 gives runtime errors in combined Fortran/C programs georg dot denk at infineon dot com
2005-08-12 12:29 ` [Bug fortran/23349] " pinskia at gcc dot gnu dot org
2005-08-12 12:45 ` georg dot denk at infineon dot com
@ 2005-08-12 22:34 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-12 22:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-12 22:34 -------
This is not a bug. You are calling a var-args function basicially what is considered a non var-args
prototype in C.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23349
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-08-12 22:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-12 8:15 [Bug fortran/23349] New: -m64 gives runtime errors in combined Fortran/C programs georg dot denk at infineon dot com
2005-08-12 12:29 ` [Bug fortran/23349] " pinskia at gcc dot gnu dot org
2005-08-12 12:45 ` georg dot denk at infineon dot com
2005-08-12 22:34 ` pinskia at gcc dot gnu dot org
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).