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

            Bug ID: 100700
           Summary: -Wreturn-type has many false positives
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gonzalo.gadeschi at gmail dot com
  Target Milestone: ---

Example (https://clang.godbolt.org/z/o85KbdG7h):

int f(unsigned i) {
  if (i < unsigned(-1)) return i;
}

enum E { A, B };

int h(E e) {
  switch (e) {
  case A: return 0;
  case B: return 0;
  }
}

compiled with g++ (no -Wall, no -Wextra) warns with:

 warning: control reaches end of non-void function [-Wreturn-type]

for "f" and "h".

Notice that clang, which implements the same warning, does not warn for "h"
(https://clang.godbolt.org/z/Ev9eqsqPf).

Reply via email to