<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 does not match MSVC in converting string literal to void*"
href="https://llvm.org/bugs/show_bug.cgi?id=30963">30963</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-cl does not match MSVC in converting string literal to void*
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dmajor@mozilla.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The conversion from string literal to char* is accepted, with a warning, but
conversion to void* is rejected.
-------------------------------------------------
$ cat foo.cpp
void c(char* ptr) {}
void v(void* ptr) {}
int main()
{
c("hello");
v("world");
return 0;
}
-------------------------------------------------
$ cl foo.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
foo.cpp
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:foo.exe
foo.obj
-------------------------------------------------
$ clang-cl -fms-compatibility-version=19.00.24215.1 foo.cpp
foo.cpp(6,5): warning: ISO C++11 does not allow conversion from string literal
to 'char *'
[-Wwritable-strings]
c("hello");
^
foo.cpp(7,3): error: no matching function for call to 'v'
v("world");
^
foo.cpp(2,6): note: candidate function not viable: no known conversion from
'const char [6]' to 'void *' for 1st argument
void v(void* ptr) {}
^
1 warning and 1 error generated.</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>