[llvm-bugs] [Bug 39040] New: statement-expression and clang-block causes incorrect compilation error
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Sep 21 10:36:28 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39040
Bug ID: 39040
Summary: statement-expression and clang-block causes incorrect
compilation error
Product: clang
Version: 7.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: remi at qumulo.com
CC: llvm-bugs at lists.llvm.org
Created attachment 20905
--> https://bugs.llvm.org/attachment.cgi?id=20905&action=edit
C program that causes the erroneous compilation error
In versions of clang before 7.0, it use to be the case that you could return a
clang-block from a gnu statement-expression just fine, but now in 7 it gives
this error for some reason:
block_statement_expression.c:4:42: error: returning block that lives on the
local stack
__auto_type f = ({ const int c = 12; ^ { return c; }; });
^~~~~~~~~~~~~~~
1 error generated.
Statement-expressions as I understand them do not allocate their own stack, and
thus it should be fine to return a block from them. And indeed if we cast the
block to (void *) and back to the block type again, the error goes away and the
code works just fine.
I think this change in behavior was unintended and is breaking existing code
that is using clang-blocks.
I invoked clang like this: clang -fblocks block_statement_expression.c
I have included a c-code example and attached it to the issue.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180921/7b746df2/attachment-0001.html>
More information about the llvm-bugs
mailing list