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: [email protected]
Reporter: [email protected]
CC: [email protected]
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._______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs