Bug#561249: g++-4.4: Spurious warning with -Wconversion (uint16_t/htons) in -O2 mode
Package: g++-4.4
Version: 4.4.2-5
Severity: normal
Consider following code:
---------- test.cpp ---------
#include <arpa/inet.h>
void test()
{
uint16_t s = 123;
// No warning expected here
uint16_t swapped = htons( s );
}
------------------------------
g++-4.4 -Wconversion -Werror -c test.cpp => no error
g++-4.4 -O2 -Wconversion -Werror -c test.cpp => error!
(this also applies to g++-4.3, not 4.2)
I don't see why the optimization changes the triggering of the warning,
this is very painful because it requires either disabling -Wconversion
or -Werror, which are not acceptable for high quality code.
Cheers
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.31-1-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages g++-4.4 depends on:
ii gcc-4.4 4.4.2-5 The GNU C compiler
ii gcc-4.4-base 4.4.2-5 The GNU Compiler Collection (base
ii libc6 2.10.2-2 GNU C Library: Shared libraries
ii libgmp3c2 2:4.3.1+dfsg-3 Multiprecision arithmetic library
ii libmpfr1ldbl 2.4.2-3 multiple precision floating-point
ii libstdc++6-4.4-dev 4.4.2-5 The GNU Standard C++ Library v3 (d
g++-4.4 recommends no packages.
Versions of packages g++-4.4 suggests:
pn g++-4.4-multilib <none> (no description available)
pn gcc-4.4-doc <none> (no description available)
pn libstdc++6-4.4-dbg <none> (no description available)
-- no debconf information
Reply to: