<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62046>62046</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Compiling Objective-C++ with ARC fails while matching types explicitly passed to templates
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RaisinTen
</td>
</tr>
</table>
<pre>
### Version info
<details>
Xcode version:
```sh
$ xcodebuild -version
Xcode 14.3
Build version 14E222b
```
Clang++ version:
```sh
$ clang++ --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
```
OS version: macOS Ventura 13.3 (22E252)
```
$ uname -a
Darwin Darshans-MacBook-Pro.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64
```
</details>
### Repro
Passing the template parameter `JSValue *` explicitly to `bind_function()` runs into a compilation error:
**`test.mm`**
```cc
#include <JavaScriptCore/JavaScriptCore.h>
template <typename ReturnType, typename... Arguments>
auto bind_function(ReturnType (^function)(Arguments...)) -> void;
void f() {
bind_function<JSValue *>(^{
JSValue *val;
return val;
});
}
```
command:
```py
$ clang++ -std=c++14 -c test.mm -fobjc-arc
test.mm:7:3: error: no matching function for call to 'bind_function'
bind_function<JSValue *>(^{
^~~~~~~~~~~~~~~~~~~~~~~~
test.mm:4:6: note: candidate template ignored: could not match 'JSValue *__strong' against 'JSValue *'
auto bind_function(ReturnType (^function)(Arguments...)) -> void;
^
1 error generated.
```
I also tried passing `JSValue *__strong` as the type in the template parameter but that too runs into the same error.
### Expectation
The same code when compiled with the same compiler options was passing in previous Xcode versions, so it should pass now.
Here is the version info of my setup when this code was compiling successfully:
<details>
Xcode version:
```sh
$ xcodebuild -version
Xcode 14.2
Build version 14C18
```
Clang++ version:
```sh
$ clang++ --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
```
</details>
### Additional info
Not passing the type explicitly compiles with no errors.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUV1tv27gS_jX0y0CERMqy_eAHxxec9pyeFklQ9C2gqbHFLkUKJOUkL_3tC0ryddOg-7C72MCIoZnh6JtvLhwL79XeIM7J-I6MVyPRhsq6-b1QXplHNKOtLV_nhPH-A1_ReWUNKLOzJF2RdDH858sSg1DaE76-VHyTtkQ49McIP5oXaf_x1SBgObxE022rdAnJ8cCFjyynvH--62wGE8jyNWNse-P4EsNSC7Mn7I6wu19DIi8OJNdYFk2jsTe4QEBTyoGwaSdPsjzlNKWM0SynGWGz_uijcHsMhC_gZVo8FXkioq-kFO5ZGcZoTgfUj5VDUUJtS9TRvLFevfSqD8YHoTWWK-WiirBNRKSkCMoaT9imI4uKpiFss7QmoAlRvMIDatugI2zzaK2WlVBn-xXuRKsDfZHhqCNs0_povVXmHW4_P1xQCrWQnx_gK5rQOgEZ71lhbM3G7MTDrR-WQ2tEjZCIXrLqGIGVcL4SxiefhLyz9rfki7NUWyk09GzBYPhfdAb1qTYHKvkCPlkDn4QDKIBlhC_SKM0m8OXhEVjKOOF34KyNOXkxbTKdzAqapRkd_-CEbe7X_1svHtZP37psDUl7hwrCl4Rt3m6DcwfdY-OuWudL7EGzh1AhBKwbLQJCI5yoMaADUqQfH74K3SIQFl8M-BITroJ-hWCjfqtM-bRrjYw1QNg0Ml2k4FrjQZlgQYC0daN0VySAzll3boAB36L3HtAHWtcxtF50Ha-Up3iUkbotEQhffhQH8SCdasLSOiRscy2g1Q0bpzAJX4bXBrvs32NonXl8bZCwJRzFlFJYuH1bd3V8dCPaYOE27LODWHRkv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