[llvm-bugs] [Bug 27192] New: ?: operator does not remove nullable

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 3 18:08:38 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27192

            Bug ID: 27192
           Summary: ?: operator does not remove nullable
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: peter at stairways.com.au
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The code:

#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wnullable-to-nonnull-conversion"

void Test()
{
    NSDictionary* d = @{};
    CGPoint location = NSPointFromString( d[@"Nothing"] ?: @"{0,0}" );
    NSLog( @"location is %@", NSStringFromPoint(location) );
}

#pragma clang diagnostic pop

Reports the warning:

>warning: implicit conversion from nullable pointer 'id _Nullable' to non-nullable pointer type 'NSString * _Nonnull' [-Wnullable-to-nonnull-conversion]
>        CGPoint location = NSPointFromString( d[@"Nothing"] ?: @"{0,0}" );

The ?: operator should be smart enough to know that if the right hand is
non-nullable then the entire expression is non-nullable.

-- 
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/20160404/0dd8176c/attachment.html>


More information about the llvm-bugs mailing list