<p dir="ltr">Intentional, I believe. We do have some warning which default to being errors. I'm not sure of the specifics of the c language standard in this case, but perhaps there's some case where this is not UB (if the return is never executed, perhaps) so it may not technically be invalid c.</p>
<div class="gmail_quote">On Oct 29, 2015 4:55 AM, "Dan Liew via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I was playing with Clang 3.7 on some old code I noticed that<br>
``-Wreturn-type`` seems to be treated as error.<br>
<br>
For example<br>
<br>
```<br>
int foo() {<br>
    int x = 5;<br>
    return;<br>
}<br>
<br>
int main() {<br>
    int x = foo();<br>
    return 0;<br>
}<br>
```<br>
<br>
Now try building<br>
```<br>
$ clang -std=c99 noret.c<br>
noret.c:3:5: error: non-void function 'foo' should return a value<br>
[-Wreturn-type]<br>
    return;<br>
    ^<br>
1 error generated.<br>
```<br>
<br>
It's good that Clang flags up bad code like this but what is confusing<br>
me is the Clang driver is<br>
<br>
* Treating this as an error even though I haven't passed ``-Werror``.<br>
* I can suppress this with ``-Wno-return-type``.<br>
<br>
So I'm not really sure if this is a "warning" or an "error". I expect<br>
<br>
* If it's an "error" then I shouldn't be able to suppress it with the<br>
``-Wno-return-type`` flag.<br>
* If it's a "warning" and I haven't passed ``-Werror`` then Clang<br>
should note the warning but not treat it as an error.<br>
<br>
Is Clang's current (and reasonable) behaviour intentional or this a bug?<br>
<br>
Thanks,<br>
Dan.<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>