Bug#281847: g++-3.4: g++ does not check arguments to fprintf
Package: g++-3.4
Version: 3.4.2-2
Severity: normal
Code snippet:
#include <cstdio>
int main (void)
{ double values [2] = { 0.1, 0.2 } ;
// This line does not raise an error.
fprintf (stdout, "values [0] = %f\n", values) ;
// While this one does.
printf ("values [0] = %f\n", values) ;
return 0;
}
Compiled with:
g++ -W -Wall test.cc -o test
Warning messages:
test.cc: In function `int main()':
test.cc:11: warning: double format, pointer arg (arg 2)
Warns about passing bad argument to printf, but not for fprintf.
-- System Information:
Debian Release: 3.1
APT prefers testing
APT policy: (700, 'testing'), (650, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.8
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (ignored: LC_ALL set to POSIX)
Versions of packages g++-3.4 depends on:
ii gcc-3.4 3.4.2-2 The GNU C compiler
ii gcc-3.4-base 3.4.2-2 The GNU Compiler Collection (base
ii libc6 2.3.2.ds1-18 GNU C Library: Shared libraries an
ii libstdc++6-dev 3.4.2-2 The GNU Standard C++ Library v3 (d
-- no debconf information
Reply to: