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

frankhb1989 at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |frankhb1989 at gmail dot com

--- Comment #6 from frankhb1989 at gmail dot com ---
struct G
  {
     template<class X> operator X() const { return *this; }
  } g;

void w(unsigned o)
  {
    extern int b[3];
    void k(int);
    switch (static_cast<unsigned char/*unsigned short*/>(o))
    case 2:
      {
        o != 2 ? nullptr : g;
        k(b[o]);
      }
  }


The indeterminately recursive case is still certainly false positive, as there
is no rule rendering the behavior undefined, and the assertion in the message
can be logically inconsistent with the fact (when the condition value is
unsigned 2); it is definitely confusing. At least the wording can be improved
(e.g. replace "is" to "may be").

In this case, it should ideally warn on the infinite recursion itself, rather
than the subsequent caller site. Besides, the discarded-value expression here
can be totally optimized away before to reason whether the call is infinitely
recursive (though it may be difficult for specific optimizing implementations).

Reply via email to