public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110839] New: Bogus -Wreturn-type for unreachable switch default case
@ 2023-07-28 7:36 rguenth at gcc dot gnu.org
2023-07-28 7:39 ` [Bug middle-end/110839] " rguenth at gcc dot gnu.org
2023-07-28 7:51 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-28 7:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110839
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 )
{
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-28 7:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28 7:36 [Bug c/110839] New: Bogus -Wreturn-type for unreachable switch default case rguenth at gcc dot gnu.org
2023-07-28 7:39 ` [Bug middle-end/110839] " rguenth at gcc dot gnu.org
2023-07-28 7:51 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).