This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/80199] New: Wlogical-op inconsistent from int to float ?


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80199

            Bug ID: 80199
           Summary: Wlogical-op inconsistent from int to float ?
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

For the following C++ code:

void g1( float );
void g2( int );

void
f1( float a)
{
        if (a < 0.0 && a > 1.0)
                g1( a);
}

void
f2( int a)
{
        if (a < 0 && a > 1)
                g2( a);
}

I get only one warning, not the expected two:

$ ~/gcc/results/bin/g++ -g -O2 -Wall -Wlogical-op -Wextra -c mar26e.cc
mar26e.cc: In function ‘void f2(int)’:
mar26e.cc:15:12: warning: logical ‘and’ of mutually exclusive tests is always
false [-Wlogical-op]
  if (a < 0 && a > 1)
      ~~~~~~^~~~~~~~
$ ~/gcc/results/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/home/dcb/gcc/results/bin/g++
COLLECT_LTO_WRAPPER=/home/dcb/gcc/results.246474/libexec/gcc/x86_64-pc-linux-gnu/7.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../trunk/configure --prefix=/home/dcb/gcc/results.246474
--disable-bootstrap --disable-multilib --disable-werror
--enable-checking=df,extra,fold,rtl,yes --enable-languages=c,c++,fortran
Thread model: posix
gcc version 7.0.1 20170325 (experimental) (GCC) 
$

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]