Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Clang with ARC bug: Incorrect Template substitution failure
Summary:
When ARC is enabled, C++ candidate templates are ignored due to an incorrectly diagnosed substitution failure.
Steps to Reproduce:
Compile the following main.mm file, with and without ARC:
#import <Foundation/Foundation.h>
template <typename T>
int testing(const T & whoCares) {
return 1;
}
int main(int argc, const char * argv[])
{
printf("%d\n", testing(1));
printf("%d\n", testing("hi"));
printf("%d\n", testing<NSString *>(@"hi"));
printf("%d\n", testing(@"hi"));
return 0;
}
Expected Results:
It should work whether or not ARC is enabled.
Actual Results:
Compilation fails with error:
main.mm:13:20: error: no matching function for call to 'testing'
printf("%d\n", testing(@"hi"));
^~~~~~~
main.mm:4:5: note: candidate template ignored: substitution failure
[with T = NSString *]
int testing(const T & whoCares) {
^
1 error generated.
Regression:
Notes:
It seems clear that the substitution failure is an incorrect determination since the template obviously works fine on line 12 where the type is being passed. AFAIK this has been broken ever since ARC was introduced.
This happens regardless of platform (iOS, Mac OS X) and is still present in Xcode 4.3.3 as well as the 4.5 developer preview 2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.