Bug#261513: gcc-3.3: strtof only in c99 but not undefined reference otherwise
Package: gcc-3.3
Version: 1:3.3.4-5
Severity: normal
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.4.24+d1
Locale: LANG=C, LC_CTYPE=C
Versions of packages gcc-3.3 depends on:
ii binutils 2.14.90.0.7-8 The GNU assembler, linker and bina
ii cpp-3.3 1:3.3.4-5 The GNU C preprocessor
ii gcc-3.3-base 1:3.3.4-5 The GNU Compiler Collection (base
ii libc6 2.3.2.ds1-13 GNU C Library: Shared libraries an
ii libgcc1 1:3.4.1-3 GCC support library
-- no debconf information
/*
The following sample code uses function "strtof".
Compiled without -std=c99 it produces some bad results instead of a
compilation error (IMHO: undefined reference to `strtof')
*/
#include <stdlib.h> /* needed for strtod and strtof */
#include <stdio.h> /* needed for fprintf */
// some related information:
// - man strtod, strtof, strtold:
// CONFORMING TO
// ANSI C describes strtod, C99 describes the other two functions.
//
// - in /usr/include/stdlib.h
//
// #ifdef __USE_ISOC99
// __BEGIN_NAMESPACE_C99
// ...
// extern float strtof (__const char *__restrict __nptr,
// char **__restrict __endptr) __THROW;
// ...
// __END_NAMESPACE_C99
// #endif
int main (void)
{
const char buf[] = "123.45";
fprintf (stdout, "result %f == %f and 6 == %d\n",
(float)strtod (buf, NULL),
strtof (buf, NULL),
6);
exit (0);
}
// ok with: gcc -Wall -std=c99 test_strtof.c
//
// without -std=c99 should get (IMHO):
//: undefined reference to `strtof'
// but instead get broken output like:
// result 123.449997 == 0.000000 and 6 == 1073970383
Reply to: