<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang-cl incorrectly treats `long` and `int` as different types on LLP, but without overload priority"
href="https://bugs.llvm.org/show_bug.cgi?id=46369">46369</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-cl incorrectly treats `long` and `int` as different types on LLP, but without overload priority
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Driver
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mike.k@digitalcarbide.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>When building with `clang-cl`, the following code does not compile:
`
#include <type_traits>
#include <cstdio>
#include <cstdint>
#if _MSC_VER
using t_int = long;
using t_long = __int64;
#else
using t_int = int;
using t_long = long;
#endif
static const char * fn(int32_t) {
return "int32";
}
static const char * fn(intptr_t) {
return "intptr";
}
#define TEST(type) std::printf(#type " = %s\n", fn(type()))
int main() {
TEST(t_int);
TEST(t_long);
return 0;
}
`
This appears to be due to `long` and `int` being entirely distinct types, and
thus not being treated as equivalent to either, and thus is an ambiguous
function call.
While this is reasonable, under the Visual C++ compiler, this compiles fine,
and it calls the `int32_t` overload. While Visual C++ appears to also treat
`long` as a distinct type, it _also_ allows secondary implicit conversion to
`int` - that is, if you provide a `long` overload, it prefers that, but if you
provide `int` and something else but no `long`, it prefers `int`.
I'd expect `clang-cl` to give equivalent behavior for compatibility purposes.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>