<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 preprocesses variadic macros differently than clang and msvc"
href="https://bugs.llvm.org/show_bug.cgi?id=43584">43584</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-cl preprocesses variadic macros differently than clang and msvc
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>9.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>berglerma@gmail.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>For all version of clang I've tested (7.0.0, 8.0.0 and 9.0.0),
#define THIRD(ARG_1, ARG_2, ARG_3, ...) ARG_3
#define DEMO(...) THIRD(__VA_ARGS__, 3, 4, 5)
int main() {
return DEMO(,);
}
turns into
int main() {
return 3;
}
when preprocessed with `clang -E demo.cpp`, but turns into
int main() {
return 4;
}
when preprocessed with `clang-cl /E demo.cpp`, regardless of whether clang-cl
is run on Linux or on Windows.
My first assumption was that clang-cl is using some kind of MSVC compatibility
mode for the preprocessor, but as it turns out it isn't doing the same thing as
msvc either: DEMO(1, 2) expands to 4 with MSVC, but to 3 with clang-cl.
Note in particular that DEMO(,) and DEMO(1, 2) expand to different results with
clang-cl, while that does not happen with MSVC.
This bug currently breaks googletest's MOCK_METHOD macro with clang-cl (see
<a href="https://github.com/google/googletest/issues/2490">https://github.com/google/googletest/issues/2490</a>)</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>