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

            Bug ID: 77796
           Summary: tautological compare warning emitted for inherited
                    static method comparisons
           Product: gcc
           Version: 6.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: linux at carewolf dot com
  Target Milestone: ---

We have been running into several issues with the tautological compare warning
in qtdeclarative, first there was https://bugreports.qt.io/browse/QTBUG-53373
(warning about comparing a typedef with its definition), and recently
https://bugreports.qt.io/browse/QTBUG-56266 (warning about a method that is
resolved to what it is compared to).

Both cases the comparison are not tautological, but merely compile time, and
specifically used in places where they need to be resolvable at compile time.
It makes no sense to warn about a comparison being resolvable at compile time a
place that demands a constexpr.

The latest example can be reproduced with this simple code:
class A {
public:
    static void destroy() { }
};

class B : public A
{
};

const int tbl[1] = {
    B::destroy == A::destroy ? 0 : 1
};

It specifically looks for whether the method has been overwritten in a derived
class, but since the names are looked up using two different scopes, it
shouldn't trigger the taulogical warning. Only comparing (A::destroy ==
A::destroy) should do that.

Reply via email to