This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
sscanf gcc 2.95.3
- From: "Luedde, Mirko" <mirko dot luedde at sap dot com>
- To: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
- Date: Wed, 2 Oct 2002 16:00:19 +0200
- Subject: sscanf gcc 2.95.3
Hello,
while I'm not a fan of `sscanf', the following appears as a bug to me.
$ uname -a
CYGWIN_NT-5.0 P73565 1.3.12(0.54/3/2) 2002-07-06 02:16 i686 unknown
$ gcc --version
2.95.3-5
$ bash --version
GNU bash, version 2.05b.0(5)-release (i686-pc-cygwin)
Copyright (C) 2002 Free Software Foundation, Inc.
$ cat classifyFloat.cpp
#include <iostream.h>
#include <stdio.h>
#include <math.h>
int main(int argc, char* argv[])
{
float x1;
float x2;
// GCC 2.95.3 on CYGWIN is broken here.
// Setting
// "x1 = 0.0 / 0.0;"
// "x2 = 1.0 / 0.0;"
// will correctly give "fpclassify(x1) == FP_NAN"
// and "fpclassify(x2) == FP_INFINITE".
//
// Not so when reading "NAN", "INF" from the keyboard.
sscanf(argv[1], "%f", &(x1));
sscanf(argv[2], "%f", &(x2));
cout
<< "FP_NORMAL = "
<< FP_NORMAL
<< endl
<< "FP_ZERO = "
<< FP_ZERO
<< endl
<< "FP_INFINTE = "
<< FP_INFINITE
<< endl
<< "FP_SUBNORMAL = "
<< FP_SUBNORMAL
<< endl
<< "FP_NAN = "
<< FP_NAN
<< endl
<< "class #1 = "
<< fpclassify(x1)
<< endl
<< "class #2 = "
<< fpclassify(x2)
<< endl;
}
$ g++ classifyFloat.cpp
$ ./a.exe NAN INF
FP_NORMAL = 4
FP_ZERO = 2
FP_INFINTE = 1
FP_SUBNORMAL = 3
FP_NAN = 0
class #1 = 3
class #2 = 2
$
On an HP machine the same program correctly gives the following
output.
$ cpp --version
aCC: HP ANSI C++ B3910B A.03.33
$ ./a.out NAN INF
FP_NORMAL = 0
FP_ZERO = 1
FP_INFINTE = 2
FP_SUBNORMAL = 3
FP_NAN = 4
class #1 = 4
class #2 = 2
$