From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 611DC3858D20; Wed, 1 May 2024 12:25:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 611DC3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714566358; bh=nfI3ZqGwTdt6XiaTrzK+RcdLNQXz2FD6aglUbwyKWrU=; h=From:To:Subject:Date:From; b=g2EWjR4nBvxi4jZMUmuj8IhxSlFUAEGs8dp4s80uA9n2gaqX9MuaE6ecvI5Rui0MK AvKdt6t17zJFY6mOVTQ+Ly6xdPMYDxt5xoVevCpY8U9OGzXJfs3SUBKTkqFvZT6t8M rz9l9dJgVoJ9rkVIppcj2DQqIiuoKLur7TR6vrj0= From: "albrecht.guendel at web dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114904] New: Bogus Warning [-Wreturn-type] in function with do-while loop Date: Wed, 01 May 2024 12:25:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: albrecht.guendel at web dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114904 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,=20 from GCC 8.1 onwards using >=3DC++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 =3D 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.=