3 ms·
> Inconsistent return statements Returning the wrong data type has been an error with Clang since the earliest days. Why does GCC still allow that?
by qalmakka 3y ago
> Inconsistent return statements
Returning the wrong data type has been an error with Clang since the earliest days. Why does GCC still allow that?
- deleted 3y ago[deleted]
- nolist_policy 3y agoIt doesn't: int main(void) { struct { int a; } s; return; return &s; return s; } $ gcc test.c test.c: In function ‘main’: test.c:5:3: warning: ‘return’ with no value, in function returning non-void 5 | return; | ^~~~~~ test.c:1:5: note: declared here 1 | int main(void) { | ^~~~ test.c:6:10: warning: returning ‘struct <anonymous> *’ from a function with return type ‘int’ makes integer from pointer without a cast [-Wint-conversion] 6 | return &s; | ^~ test.c:7:10: error: incompatible types when returning type ‘struct <anonymous>’ but ‘int’ was expected 7 | return s; | ^