Subject: Converting long double to integer types
To: NetBSD/sparc64 Port <port-sparc64@NetBSD.org>
From: Holger Weiss <lists@jhweiss.de>
List: port-sparc64
Date: 11/05/2007 15:30:44
On 4.99.30, the following code spits out "x=2 y=1":
/* ------------------------------ */
#include <stdio.h>
int
main(void)
{
long double ld = 1.9;
int x = ld;
int y = (double)ld;
printf("x=%d y=%d\n", x, y);
return 0;
}
/* ------------------------------ */
AFAICS, "x=2" clearly violates the standard, no?
I can reproduce this both with GCC 4.1.3 from base and GCC 3.3.6 from
pkgsrc; I cannot reproduce it with GCC 3.4.3 on Solaris/sparc64.
Holger