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/65620] New: Incorrect warning for !! with -Wlogical-not-parentheses


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

            Bug ID: 65620
           Summary: Incorrect warning for !! with
                    -Wlogical-not-parentheses
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andi-gcc at firstfloor dot org

Created attachment 35172
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35172&action=edit
test case

When building the linux 4.0-rc5 kernel with 5.0 there are several imho
bogus warnings like

warning: logical not is only applied to the left hand side of comparison
[-Wlogical-not-parentheses]

for constructs like this:

  !!test_bit(...) != ...

The warning shouldn't warn for !! which is reasonably common. Looking at the
c/cp parsers there is already code to check for this, but it doesn't seem to
work here.

In the kernel case test_bit actually expands to a complex macro like

 if (usage->type == 0x01  && !!(__builtin_constant_p((usage->code)) ?         
          constant_test_bit((usage->code), (input->key)) :
variable_test_bit((usage->key),                       
               (input->key)))

I'm attaching an (already delta'ed but still quite big) test case

C++ likely has the same problem (but not tested)


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