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

ORiordan, Martin via cfe-dev cfe-dev at lists.llvm.org
Thu Oct 5 01:25:41 PDT 2017

Haha, 7 years.  I tried with v4.0 and it was there too, but I did not look further back.  Yes, the test case is contrived, but part of ANSI C89 validation.  I am not aware of any real-world-code that is still around that depends on this though.

All the best,


From: Friedman, Eli [mailto:efriedma at codeaurora.org]
Sent: Wednesday, October 4, 2017 7:15 PM
To: ORiordan, Martin <martin.oriordan at intel.com>; Clang Dev <cfe-dev at lists.llvm.org>
Subject: Re: [cfe-dev] Unexpected error when compiling for ANSI C89

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) {
I get the following error message:
xxx.c:2:3: error: non-void function 'foo' should return a value [-Wreturn-type]
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<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.



Employee of Qualcomm Innovation Center, Inc.

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263

This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171005/2cfd3513/attachment.html>

More information about the cfe-dev mailing list