>Submitter-Id: net >Originator: >Organization: Debian Project >Confidential: no >Synopsis: Generates bad code for indirect calls on pa-risc >Severity: serious >Priority: medium >Category: target >Class: wrong-code >Release: 3.0.3 (Debian testing/unstable) >Environment: System: Linux sarti 2.4.16-64 #1 Fri Dec 7 16:08:36 MST 2001 parisc64 unknown Architecture: parisc64
host: hppa-unknown-linux-gnu build: hppa-unknown-linux-gnu target: hppa-unknown-linux-gnu configured with: ../src/configure -v --enable-languages=c,c++,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --with-cpp-install-dir=bin hppa-linux >Description: The Ghostscript binary built with gcc 3.0.3 on pa-risc is incorrect. I tracked the problem to the code generated by gcc when calling a function via a function pointer. Interestingly this only applies to the floating point arguments. Everything else seems to work fine. Here is what I consider a very nice example of the problem: --- #include <stdio.h> void out(const char *str, double x) { printf("%s: %f\n", str, x); } int main(int argc, char **argv) { void (*f)(const char *, double) = out; f("Calling via function pointer", 3.1415926535); out("Calling directly", 3.1415926535); return 0; } --- The output of this program is as follows: --- [EMAIL PROTECTED]:~/gccbug$ gcc realind.c -o realind -lm [EMAIL PROTECTED]:~/gccbug$ ./realind Calling via function pointer: 0.000000 Calling directly: 3.141593 --- >How-To-Repeat: Building the program above should suffice for repeating the problem. Let me know if it works on your system :) >Fix: I don't know a viable work around. You could avoid using function pointers or pass the floating point values by reference.