[LLVMbugs] [Bug 15865] New: Clang fails to match ObjC pointers to pointer template parameters under ARC

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 29 10:37:41 PDT 2013


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

            Bug ID: 15865
           Summary: Clang fails to match ObjC pointers to pointer template
                    parameters under ARC
           Product: clang
           Version: 3.2
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: scoward at pivotallabs.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Summary:
When ARC is enabled, C++ candidate templates' pointer template parameters fail
to match objective-C object pointers.


Steps to reproduce:
Compile the following main.mm file, with and without ARC:

#import <Foundation/Foundation.h>

template <typename T>
void testing(const T & whoCares) {
    NSLog(@"================> Non pointer template");
}

template <typename T>
void testing(T * const & whoCares) {
    NSLog(@"================> Pointer template");
}

int main(int argc, const char * argv[])
{
    NSString *stringObject = @"hi";
    char *cString = "abc";
    testing(1);
    testing(cString);
    testing(stringObject);
    testing<NSString>(stringObject);
    return 0;
}


Expected Results:
The template with the pointer parameter should be instantiated for cString and
stringObject, without needing to parameterize the template explicitly, as
demonstrated by the output when compiled without ARC:

================> Non pointer template
================> Pointer template
================> Pointer template
================> Pointer template


Actual Results:
When ARC is enabled and the template is not parameterized explicitly, the
non-pointer template is instantiated if the pointer is an objective-c type, as
demonstrated by the output when compiled with ARC:

================> Non pointer template
================> Pointer template
================> Non pointer template         <== WRONG
================> Pointer template

-- 
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/20130429/49325757/attachment.html>


More information about the llvm-bugs mailing list