[LLVMbugs] [Bug 15257] New: Clang hangs with Class string literal comparison

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Feb 13 13:07:15 PST 2013


            Bug ID: 15257
           Summary: Clang hangs with Class string literal comparison
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dustin.clark at emerson.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Hi guys, this is kind of a weird issue discovered yesterday as a result of
updating a CI server with the latest version of Xcode. 

I've generalized what the team member was trying to do and while it's not
correct/ideal -- I don't imagine it's intended to cause a hangup.

$ cat bug.m
int main(int argc, const char * argv[])
    NSString *string = [[NSString alloc] init];
    if (string.class == @"NSString") NSLog(@"Foo");

    return 0;

With the older version:

$ clang --version
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix
$ clang -framework Cocoa bug.m -o bug

With the newer version:

Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix
-framework Cocoa bug.m -o bug
bug.m:6:19: warning: direct comparison of a string literal has undefined
behavior [-Wobjc-string-compare]
        if (string.class == @"NSString") NSLog(@"Foo");
                         ^  ~~~~~~~~~~~

And now clang is, indefinitely, hanging at 100% CPU. 

I've fixed the issue on our end by having them correctly use isKindOfClass or
NSStringFromClass :) -- but I thought I would file the bug incase it's unknown.

Thanks for your time -- and I sincerely apologize if this is a duplicate 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/20130213/f8d58d80/attachment.html>

More information about the llvm-bugs mailing list