From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3361E384F8F0; Fri, 28 Jul 2023 07:36:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3361E384F8F0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690529765; bh=2QtCUQXAAIHIdv3H5gastsI4e1KIL6Js3d1d/jqtnro=; h=From:To:Subject:Date:From; b=VQd8/WuAfpE8XJwvA27vV7vxbRIclcj8wavh9qJlJY0t9jqwFSqCtivuqkVn0n4K0 nGLBYFQ963+0U8u93Js4RnMun4QKWYdXNH6KqNXXpvcuhz/pqGou/PbvxXGHhkaUzT SJhmC3NuWOlYWk3HrsY4WUZu1b4rYbVW2YyeUTnY= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/110839] New: Bogus -Wreturn-type for unreachable switch default case Date: Fri, 28 Jul 2023 07:36:04 +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.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org 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=3D110839 Bug ID: 110839 Summary: Bogus -Wreturn-type for unreachable switch default case Product: gcc Version: 13.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- unsigned char random_ui8(void); int f16RandomQOutP3 (void); int f16RandomQOutPInf (void); int f16RandomQInfP3 (void); int f16RandomQInfPInf (void); int f16Random( void ) {=20=20=20 switch ( random_ui8() & 7 ) { case 0: case 1: case 2: return f16RandomQOutP3(); case 3: return f16RandomQOutPInf(); case 4: case 5: case 6: return f16RandomQInfP3(); case 7: return f16RandomQInfPInf(); } } diagnoses gcc -S t.c -O2 -Wreturn-type t.c: In function 'f16Random': t.c:23:1: warning: control reaches end of non-void function [-Wreturn-type] 23 | } | ^ this is because pass_warn_function_return runs after lowering before any optimization is done and the gimplifier adds a default: case that falls through to the function end.=