Bug#319553: g++-4.0: HUGE_VAL causes error with -pedantic
Package: g++-4.0
Version: 4.0.1-2
Severity: normal
Hi,
I've run into a build failure whilst transitioning one of my packages to
g++-4.0. The error occurs when HUGE_VAL is used with -pedantic in C++ code,
as in the following program:
#include <math.h>
int main() {
double d = 1.0;
if (d == HUGE_VAL)
return 1;
return 0;
}
When compiled with g++-3.3, it prints a warning (use of C99 hexadecimal
floating constant, as described elsewhere in #231748) but compiles fine.
example:~> g++-3.3 -pedantic huge_val.cc
huge_val.cc:6:14: warning: use of C99 hexadecimal floating constant
example:~>
However, when compiled with g++-4.0 it prints the same warning and then
gives an error (floating constant exceeds range of 'double').
example:~> g++-4.0 -pedantic huge_val.cc
huge_val.cc:6:14: warning: use of C99 hexadecimal floating constant
huge_val.cc:6: error: floating constant exceeds range of 'double'
example:~>
If you remove the -pedantic, it compiles fine. If you compile it with
gcc-4.0 as a C program, it also compiles fine (just the warning, no error).
example:~> g++-4.0 huge_val.cc
example:~> gcc-4.0 -pedantic huge_val.c
huge_val.c:6:14: warning: use of C99 hexadecimal floating constant
example:~>
I'm filing this as a separate bug from #231748, since it occurs in
different contexts (v4.0 only, C++ only), the error is different and
the result is more severe (build failure, not just warning).
Ben.
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.10-1-686-smp
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Versions of packages g++-4.0 depends on:
ii gcc-4.0 4.0.1-2 The GNU C compiler
ii gcc-4.0-base 4.0.1-2 The GNU Compiler Collection (base·
ii libc6 2.3.2.ds1-22 GNU C Library: Shared libraries an
ii libstdc++6-4.0-dev 4.0.1-2 The GNU Standard C++ Library v3 (d
g++-4.0 recommends no packages.
-- no debconf information
Reply to: