Re: [NOVICE] Postgres storing time in strange manner - Mailing list pgsql-bugs

From Tom Lane
Subject Re: [NOVICE] Postgres storing time in strange manner
Date
Msg-id 17450.1032359201@sss.pgh.pa.us
Whole thread Raw
In response to Re: [NOVICE] Postgres storing time in strange manner  (Sean Chittenden <sean@chittenden.org>)
Responses Re: [NOVICE] Postgres storing time in strange manner
Re: [NOVICE] Postgres storing time in strange manner
List pgsql-bugs
Sean Chittenden <sean@chittenden.org> writes:
> Is there a place where -fno-fast-math
> could be used as a CC option if the CC is gcc?

configure is what I had in mind ;-).  I can't think of any part of the
code where we'd really want this sort of optimization enabled.

> After looking through gcc, using -O and -ffast-math will create broken
> code, but -O2 -ffast-math _should_ be okay.

At least in the gcc shipped with Red Hat 7.2, it doesn't seem to matter:
you get the wrong answer regardless of -O level.  Here's the test case
I used:

[tgl@rh1 tgl]$ cat bug.c
#include <stdio.h>

double d18000 = 18000.0;

main() {
  int d = d18000 / 3600;
  printf("18000.0 / 3600 = %d\n", d);
  return 0;
}
[tgl@rh1 tgl]$ gcc  bug.c
[tgl@rh1 tgl]$ ./a.out
18000.0 / 3600 = 5                -- right
[tgl@rh1 tgl]$ gcc -O2 -ffast-math bug.c
[tgl@rh1 tgl]$ ./a.out
18000.0 / 3600 = 4                -- wrong
-- I get 4 if -ffast-math, -O doesn't affect it
[tgl@rh1 tgl]$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)

            regards, tom lane

pgsql-bugs by date:

Previous
From: Sean Chittenden
Date:
Subject: Re: [NOVICE] Postgres storing time in strange manner
Next
From: Sean Chittenden
Date:
Subject: SET autocommit begins transaction?