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

[Bug c++/24522] New: htonl in optimized template function generates compiler warning

Overview Description: More detailed expansion of summary.

        When compiling template functions in g++ 4.0.2 (Debian 4.0.2-2) (Debian
testing/unstable) with -O2 and -Wall, the compiler generates a warning about a
statement with no effect.  This seems to be due to the inlining with __v; as a
statement, but the warning does not occur in non-template functions or with
other compiler versions tried (3.4).

    Steps to Reproduce: Minimized, easy-to-follow steps that will trigger the
bug. Include any special setup steps.

        1) Create the following .cc file (as test.cc):
#include <netinet/in.h>

template<typename S>
void serialize(const uint32_t* pitem, const S& item) {
  uint32_t t2 = htonl(item);

        2) Compile "test.cc"
$ g++ -O2 -Wall -c -o test.o test.cc

    Actual Results: What the application did after performing the above steps.

        g++ generated a warning that the htonl statement has no effect.
$ g++ -O2 -Wall -c -o test.o test.cc
test.cc: In function 'void serialize(const uint32_t*, const S&)':
test.cc:5: warning: statement has no effect

    Expected Results: What the application should have done, were the bug not

        test.o should have been created without warning

    Build Date & Platform: Date and platform of the build that you first
encountered the bug in.

>Release:       4.0.2 (Debian 4.0.2-2) (Debian testing/unstable)
configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib
--libexecdir=/usr/lib--without-included-gettext --enable-threads=posix
--enable-nls --program-suffix=-4.0 --enable-__cxa_atexit
--enable-libstdcxx-allocator=mt --enable-clocale=gnu--enable-libstdcxx-debug
--enable-java-gc=boehm --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0- --enable-mpfr
--disable-werror --enable-checking=release i486-linux-gnu
System: Linux killian.ucsd.edu #1 SMP Wed Oct 19 09:24:47
PDT 2005 i686 GNU/Linux
Architecture: i686

    Additional Builds and Platforms: Whether or not the bug takes place on
other platforms (or browsers, if applicable).

        - Also Occurs On        

        - Doesn't Occur On        
        g++ version 3.4.4 20050721 (Red Hat 3.4.4-2)
        Or without -O2, -Wall, or outside of a template function.

           Summary: htonl in optimized template function generates compiler
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ckillian at cs dot ucsd dot edu
 GCC build triplet: i486-pc-linux-gnu
  GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu


------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

Reply to: