Skip site navigation (1) Skip section navigation (2)

Re: OpenBSD/Sparc status

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stefan Kaltenbrunner <stefan(at)kaltenbrunner(dot)cc>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>,pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: OpenBSD/Sparc status
Date: 2004-11-19 18:55:33
Message-ID: 7361.1100890533@sss.pgh.pa.us (view raw, whole thread or download thread mbox)
Thread:
Lists: pgsql-hackers
The answer is: it's a gcc bug.  The attached program should print
x = 12.3
y = 12.3

but if compiled with -O or -O2 on Stefan's machine, I get garbage:

$ gcc -O  ftest.c
$ ./a.out
x = 12.3
y = 1.47203e-39
$ gcc -v
Reading specs from /usr/lib/gcc-lib/sparc64-unknown-openbsd3.6/3.3.2/specs
Configured with:
Thread model: single
gcc version 3.3.2 (propolice)
$

			regards, tom lane


#include <stdio.h>

float
returnfloat(float *x)
{
	return *x;
}

int
main()
{
	float x = 12.3;
	union {
		float f;
		char *t;
	} y;

	y.f = returnfloat(&x);

	printf("x = %g\n", x);
	printf("y = %g\n", y.f);

	return 0;
}

Responses

pgsql-hackers by date

Next:From: David FetterDate: 2004-11-19 18:56:42
Subject: Re: [Plperlng-devel] Re: Concern about new PL/Perl
Previous:From: Joshua D. DrakeDate: 2004-11-19 18:54:04
Subject: Re: Test database for new installs?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group