Package: gcc-4.0 Version: 4.0.2-3 Severity: normal
When I compile the following program like this: gcc -Wall t2.cpp I get this warning: t2.cpp: In function 'int x(T)': t2.cpp:11: warning: statement has no effect t2.cpp: In function 'int x3(T)': t2.cpp:25: warning: statement has no effect When I compile the program with gcc-3.4 I get no warning. The statement DOES have an effect, its value is the value of the ({ ... }) parantheses. Without it would give a syntax error. The code in the return statement was taken from standard header files (bits/byteswap.h) Here it is the file t2.cpp: template<typename T> int x(T t) { return (__extension__ ( { register unsigned short int __v, __x = (t); if (__builtin_constant_p (__x)) __v = ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)); else __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc"); __v; } )); } template<typename T> int x3(T t) { return ( { register unsigned short int __v, __x = (t); if (__builtin_constant_p (__x)) __v = ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)); else __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc"); __v; }); } template<typename T> int x2(T t) { register unsigned short int __v, __x = (t); if (__builtin_constant_p (__x)) __v = ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)); else __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc"); return __v; } int main() { int z=4,y,y2,y3; y=x(z); y2=x2(z); y3=x3(z); return 0; } Some info about gcc: it is from debian unstable, latest. Output of gcc -v --save-temp -Wall t2.cpp: Using built-in specs. Target: i486-linux-gnu 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-1.4.2.0/jre --enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu Thread model: posix gcc version 4.0.3 20051023 (prerelease) (Debian 4.0.2-3) /usr/lib/gcc/i486-linux-gnu/4.0.3/cc1plus -E -quiet -v -D_GNU_SOURCE t2.cpp -mtune=i486 -Wall -fpch-preprocess -o t2.ii ignoring nonexistent directory "/usr/local/include/i486-linux-gnu" ignoring nonexistent directory "/usr/include/i486-linux-gnu" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../include/c++/4.0.3 /usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../include/c++/4.0.3/i486-linux-gnu /usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../include/c++/4.0.3/backward /usr/local/include /usr/lib/gcc/i486-linux-gnu/4.0.3/include /usr/include End of search list. /usr/lib/gcc/i486-linux-gnu/4.0.3/cc1plus -fpreprocessed t2.ii -quiet -dumpbase t2.cpp -mtune=i486 -auxbase t2 -Wall -version -o t2.s GNU C++ version 4.0.3 20051023 (prerelease) (Debian 4.0.2-3) (i486-linux-gnu) compiled by GNU C version 4.0.3 20051023 (prerelease) (Debian 4.0.2-3). GGC heuristics: --param ggc-min-expand=62 --param ggc-min-heapsize=60528 t2.cpp: In function 'int x(T)': t2.cpp:11: warning: statement has no effect t2.cpp: In function 'int x3(T)': t2.cpp:25: warning: statement has no effect as -V -Qy --32 -o t2.o t2.s GNU assembler version 2.16.91 (i486-linux-gnu) using BFD version 2.16.91 20050902 Debian GNU/Linux /usr/lib/gcc/i486-linux-gnu/4.0.3/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/crt1.o /usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/crti.o /usr/lib/gcc/i486-linux-gnu/4.0.3/crtbegin.o -L/usr/lib/gcc/i486-linux-gnu/4.0.3 -L/usr/lib/gcc/i486-linux-gnu/4.0.3 -L/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib -L/usr/lib/gcc/i486-linux-gnu/4.0.3/../../.. -L/lib/../lib -L/usr/lib/../lib t2.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i486-linux-gnu/4.0.3/crtend.o /usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/crtn.o -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/dash Kernel: Linux 2.6.14-1-k7 Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1) Versions of packages gcc-4.0 depends on: ii binutils 2.16.1cvs20050902-1 The GNU assembler, linker and bina ii cpp-4.0 4.0.2-3 The GNU C preprocessor ii gcc-4.0-base 4.0.2-3 The GNU Compiler Collection (base ii libc6 2.3.5-6 GNU C Library: Shared libraries an ii libgcc1 1:4.0.2-3 GCC support library Versions of packages gcc-4.0 recommends: ii libc6-dev 2.3.5-6 GNU C Library: Development Librari ii libmudflap0-dev 4.0.2-3 GCC mudflap support libraries (dev -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]