[cfe-dev] Unexpected error when compiling for ANSI C89

Friedman, Eli via cfe-dev cfe-dev at lists.llvm.org
Wed Oct 4 11:14:57 PDT 2017


On 10/4/2017 3:47 AM, ORiordan, Martin via cfe-dev wrote:
>
> Hi CFE-Devs,
>
> When I compile the following tiny test with ‘-std=c89’ (‘clang 
> –std=c89 –c xxx.c’):
>
> foo(x) {
>
> return;
>
> }
>
> I get the following error message:
>
> xxx.c:2:3: error: non-void function 'foo' should return a value 
> [-Wreturn-type]
>
> return;
>
> ^
>
> 1 error generated.
>

Looks like an oversight in https://reviews.llvm.org/rL108108; in C99, we 
want to default to an error, but C89 we shouldn't, as you've pointed 
out.  See also https://bugs.llvm.org//show_bug.cgi?id=12216.

That said, it's been like this for seven years... it seems like this 
isn't causing issues in practice.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171004/ec453e65/attachment.html>


More information about the cfe-dev mailing list