Bug in builtin_apply and friends

John W. Stevens jstevens@basho.fc.hp.com
Wed Sep 8 13:35:00 GMT 1999


I just compiled and installed GCC 2.95.1 on an PA-RISC based HPUX 10.20
workstation, using the EGCS 1.1.2 compiler and the GNU assembler (note:
I am unable to use the native HPUX 10.20 assembler to build GCC, GAS
must be used).

The following program exhibits a long standing (PA-RISC) bug in one of the 
following:

__builtin_return
__builtin_apply
__builtin_apply_args

functions.

Program source:

Cut Here (s.c)=================================================================
float
ret_f(
    float   f)
{
    float rf(float f) { printf("rf f: %f\n", f); return f; }

    printf("ret_f f: %f\n", f);
    __builtin_return(
        __builtin_apply(
            (void (*)()) rf,
            __builtin_apply_args(),
            0) );
}

int
main(void)
{
    auto    float    f = 3.141593;

    printf("Float: %f\n", ret_f( f ));
}
Cut Here ======================================================================

Running gcc on the above source (using the command line: gcc -o s s.c), then
running the program gives:

ret_f f: 3.141593
rf f: 0.000000
Float: 0.000000

Suggesting that either:

__builtin_apply
__builtin_apply_args

has the bug.

This bug impacts the ability to use GCC 2.95.1 as an Objective-C
compiler in the GNUstep project.

Note that this test program, unchanged, works correctly on i386, Linux,
egcs 1.1.2 and gcc 2.8.1.

I am attempting to investigate the problem, but would appreciate emails
from anybody who is familiar enough with the GCC PA-RISC machine
description and GCC internals to help me localize the possible problem
area.

Thanks,
John S.

GCC Info:

gcc version number: 2.95.1
System Type       : Visualize C360 (PA-RISC chip) running HPUX 10.20.
Compiler options  : Nothing but -o to name output file.

Result of running gcc -v --save-temps -o s s.c:

Reading specs from /usr/local/lib/gcc-lib/hppa2.0-hp-hpux10.20/2.95.1/specs
gcc version 2.95.1 19990816 (release)
 /usr/local/lib/gcc-lib/hppa2.0-hp-hpux10.20/2.95.1/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -Dhppa -Dhp9000s800 -D__hp9000s800 -Dhp9k8 -DPWB -Dhpux -Dunix -D__hppa__ -D__hp9000s800__ -D__hp9000s800 -D__hp9k8__ -D__PWB__ -D__hpux__ -D__unix__ -D__hppa -D__hp9000s800 -D__hp9k8 -D__PWB -D__hpux -D__unix -Asystem(unix) -Asystem(hpux) -Acpu(hppa) -Amachine(hppa) -D__hp9000s700 -D_PA_RISC1_1 -D_HPUX_SOURCE -D_HIUX_SOURCE s.c s.i
GNU CPP version 2.95.1 19990816 (release) (hppa)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc-lib/hppa2.0-hp-hpux10.20/2.95.1/../../../../hppa2.0-hp-hpux10.20/include
 /usr/local/lib/gcc-lib/hppa2.0-hp-hpux10.20/2.95.1/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /usr/local/lib/gcc-lib/hppa2.0-hp-hpux10.20/2.95.1/../../../../include/g++-3
End of omitted list.
 /usr/local/lib/gcc-lib/hppa2.0-hp-hpux10.20/2.95.1/cc1 s.i -quiet -dumpbase s.c -version -o s.s
GNU C version 2.95.1 19990816 (release) (hppa2.0-hp-hpux10.20) compiled by GNU C version 2.95.1 19990816 (release).
 /usr/local/bin/as -o s.o s.s
 /usr/local/lib/gcc-lib/hppa2.0-hp-hpux10.20/2.95.1/collect2 -L/lib/pa1.1 -L/usr/lib/pa1.1 -z -u main -o s /usr/ccs/lib/crt0.o -L/usr/local/lib/gcc-lib/hppa2.0-hp-hpux10.20/2.95.1 -L/usr/ccs/bin -L/usr/ccs/lib -L/usr/local/lib s.o -lgcc -lc -lgcc

Contents of s.i:

Cut Here (s.i)=================================================================
# 1 "s.c"
float
ret_f(
	float	f)
{
	float rf(float f) { printf("rf f: %f\n", f); return f; }

	printf("ret_f f: %f\n", f);
	__builtin_return(
		__builtin_apply(
			(void (*)()) rf,
			__builtin_apply_args(),
			0) );
}

int
main(void)
{
	auto	float	 f = 3.141593;

	printf("Float: %f\n", ret_f( f ));
}
Cut Here ======================================================================


More information about the Gcc-bugs mailing list