[Bug sanitizer/91389] [7/8/9/10 Regression] error: control reaches end of non-void function with -fsanitize=thread since r219201

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Aug 7 14:16:00 GMT 2019


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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Don't do it then?  The no fallthru early discovery isn't perfect and with the
sanitizer instrumentation it gets even harder.
Looks like a dup of PR86899 to me anyway.
If I do a small modification like:
class A {
  struct B {
    enum {} type;
  };
  B *m_fn1();
};
struct C { C (); ~C (); };
A::B *A::m_fn1() {
  C c;
  B *a;
  switch (a->type) {
    break;
  default:
    return a;
  }
}
then it emits the false positive warning even with just -O0 -Wreturn-type.
I really think it doesn't hurt if people remove the clearly unreachable code
from their code to get rid of this warning.


More information about the Gcc-bugs mailing list