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

            Bug ID: 83280
           Summary: gcc doesn't realize a returning value from complete
                    switch(enum...) does return a value
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gu...@henkel-wallace.org
  Target Milestone: ---

Given this file:
===========
enum class e { a, b, c};

int converter (e val);

int converter (e val) {
 switch (val) {
 case e::a: return 0;
 case e::b: return 1;
 case e::c: return 2;
 }
}
===========

g++ 7.2 doesn't realize this function always returns correctly:

   $ g++-7 -Wswitch -Wreturn-type -std=c++11 -c enum-problem.cc
   enum-problem.cc: In function 'int converter(e)':
   enum-problem.cc:13:1: warning: control reaches end of non-void function
[-Wreturn-type]
    }
    ^
   $

Reply via email to