https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125350
Bug ID: 125350
Summary: Spurious -Wreturn-type if both an if condition is
illegal but both branches return
Product: gcc
Version: 16.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: blubban at gmail dot com
Target Milestone: ---
int x()
{
if (1 << 1.0)
return 2;
else
return 3;
}
Needs -Wreturn-type (or compiling as C++, where it's on by default).
https://godbolt.org/z/MssvvsvEr
Expected:
<source>: In function 'x':
<source>:3:15: error: invalid operands to binary << (have 'int' and 'double')
3 | if (1 << 1.0)
| ^~
Actual: The above, but also
<source>:7:1: warning: control reaches end of non-void function [-Wreturn-type]
7 | }
| ^
(Originally found by forgetting a few operator== overloads in C++; I'm not sure
if this belongs in the C component, but I can't find a 'reproduces in both C
and C++' component.)