[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#488884: g++-4.3: Option -O{1,2,3} generates spurious warnings with -Wconversion



Package: g++-4.3
Version: 4.3.1-4
Severity: normal


The following file compiles without warning with:
$ g++ -Wconversion -c htons.cpp

but generates a warning with :
$ g++ -O2 -Wconversion -c htons.cpp
(also with -O1 or -O3)

This basically generates spurious warnings
or even prevents building if strict -Werror is used.

------------------------------------------
#include <netinet/in.h>
#include <arpa/inet.h>

void test( int port )
{
  struct sockaddr_in sa;
  sa.sin_port = htons( (uint16_t)port ); // << Warning here in optimized mode
}
-------------------------------------

Sincerely


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.25-2-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/bash

Versions of packages g++-4.3 depends on:
ii  gcc-4.3                   4.3.1-4        The GNU C compiler
ii  gcc-4.3-base              4.3.1-4        The GNU Compiler Collection (base 
ii  libc6                     2.7-12         GNU C Library: Shared libraries
ii  libgmp3c2                 2:4.2.2+dfsg-3 Multiprecision arithmetic library
ii  libmpfr1ldbl              2.3.1.dfsg.1-2 multiple precision floating-point 
ii  libstdc++6-4.3-dev        4.3.1-4        The GNU Standard C++ Library v3 (d

g++-4.3 recommends no packages.

-- no debconf information



Reply to: