compiling the following functions with g++ -Wlogical-op leads to a wrong
warning

---------

template<class C> void Test()
{
        if ((1 == 2) || (true)) { // warning: logical &#8216;||&#8217; with
non-zero constant will always evaluate as true
        }

        if ((1 == 2) || (!false)) {
        }

        if (false || true) {
        }
}



int main() {
        if ((1 == 2) || (true)) {
        }
}

---------

Warning occurs only in the first if inside the template.

> g++-4.3 -v
Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --with-local-prefix=/usr/local
--infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64
--libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.3
--enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/
--with-pkgversion='SUSE Linux' --disable-libgcj --with-slibdir=/lib64
--with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new
--disable-libstdcxx-pch --program-suffix=-4.3
--enable-version-specific-runtime-libs --enable-linux-futex
--without-system-libunwind --with-cpu=generic --build=x86_64-suse-linux
Thread model: posix
gcc version 4.3.2 20080715 (prerelease) [gcc-4_3-branch revision 137837] (SUSE
Linux)


-- 
           Summary: Wrong warning with -Wlogical-op
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: olaf at bonorden dot de
 GCC build triplet: x86_64-suse-linux
  GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36954

Reply via email to