https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114904
Bug ID: 114904 Summary: Bogus Warning [-Wreturn-type] in function with do-while loop Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: albrecht.guendel at web dot de Target Milestone: --- Hi, from GCC 8.1 onwards using >=C++14, i get hit with > warning: control reaches end of non-void function [-Wreturn-type] in the following code: auto test() { do { volatile int a = 0; if (a) continue; return 1; } while(0); } or use https://godbolt.org/z/PxE95vqe6 This code uses a do-while construct to conditionally repeat code above the continue-statement, but always returns within the loop. The bogus warning occurs as soon as loop-control-flow is added. However the 'continue' would never leave the loop. The warning can be fixed with __builtin_unreachable(); below the while(0). or by using goto instead of loop control-flow. However this should not be necessary. Clang shows the same behavior.