[LLVMbugs] [Bug 15663] New: GNU "a?:b" ternary operator with blocks causes bus error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 3 14:40:20 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=15663

            Bug ID: 15663
           Summary: GNU "a?:b" ternary operator with blocks causes bus
                    error
           Product: clang
           Version: trunk
          Hardware: All
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arthur.j.odwyer at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 10283
  --> http://llvm.org/bugs/attachment.cgi?id=10283&action=edit
Output of "clang test.c -v"

cat >test.c <<EOF
void (^b)() = ^{};
int main() {
    (b ?: ^{})();
}
EOF
clang test.c
./a.out

Bus error: 10

Notice that "void (^b)()" is the Apple Blocks extension, and "?:" is the GNU
ternary operator — "a ?: b" is equivalent to "a ? a : b" except that "a" is
evaluated only once.

This reproduces in Objective-C (test.m) as well as in C (test.c).

Replacing the offending expression with (^{} ?: ^{}) avoids the bus error.
Replacing it with (b ?: b) also avoids the bus error.

In my unreduced code, "b" was a complicated expression with side effects that
could in fact be NULL (hence my use of the GNU ternary operator), but it turns
out that this is not relevant to reproducing the bug.

-- 
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/20130403/ed27757d/attachment.html>


More information about the llvm-bugs mailing list