http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53095
Bug #: 53095
Summary: std=gnu99 atof x86
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 27227
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27227
the preprocessed file (*.i*) that triggers the bug
/*
Exact version of GCC: That I know that version 4.3, 4.6 and 4.7 has this bug.
System Type: x86_32, i686, 32BITS Intel architecture. It don't occurs in 64 bit
intel architectures.
Options given when GCC was configured/build: The error happen when you use
-std=gnu99 ¡¡BY DEFAULT :O!! standar or -std=gnu89, but not when you use other
standar like -std=c99
The complete command line that triggers the bug: "gcc main.c -o main"
The compiler output (error messages, warnings, etc.): None.
the preprocessed file (*.i*) that triggers the bug, generated by adding
-save-temps to the complete compilation command, or, in the case of a bug
report for the GNAT front end, a complete set of source files (see below): As
attachment
Thank's I love GNU & your work a million of thanks.
*/
#include <stdio.h>
#include <stdlib.h>
int main(){
char *cadena = "-25.9";
//USING A TEMP VARIABLE
double d = atof(cadena) * 10;
short s1 = (short) d;
printf("%d\n",s1); //I GET -259
//WITHOUT A TEMP VARIABLE
short s2 = atof(cadena) * 10;
printf("%d\n",s2); //I GET -258????????????????????????????? WTF?
}