[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A bug or a mis-feature ?
From: |
Mario Stipcevic |
Subject: |
A bug or a mis-feature ? |
Date: |
Thu, 19 Apr 2001 10:36:31 +0200 |
Hi there !
I foun (the hard way) that atof() and strtod() functions in gcc 2.91.66
and 2.95.2 have an inetersting "feature" (or a bug) that was not
present in
older compilers (say 2.7.2.3) and is mostprobably NOT TO THE ANSI
standard.
In short:
atof("infXXXX") returns a big nuumber instead of zero. This is
disturbing since if I have any string beginning with "inf" I will
get a non-zero return from atof(). The same goes for
strtod("infXXX",'\0').
Is this a bug ? Will you fix it ? If not, how can I avoid this
unexpected behavuiour ? I tried -ansi option to gcc, it does not help !
Example:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char line_S[10];
long g_long;
float x;
strcpy(line_S, "infanything");
g_long=atof(line_S);
printf("%s %d %f\n", line_S, g_long, atof(line_S));
}
Cheers,
Mario Stipcevic,
Zagreb
- A bug or a mis-feature ?,
Mario Stipcevic <=