<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 --- - 64-bit clang-cl does not discard the __unaligned attribute on pointers when casting"
href="https://llvm.org/bugs/show_bug.cgi?id=30578">30578</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>64-bit clang-cl does not discard the __unaligned attribute on pointers when casting
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>froydnj@gmail.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>This testcase, cut down from code in Firefox, compiles with 64-bit MSVC but
does not compile with 64-bit clang-cl:
typedef struct _ITEMIDLIST
{
void* mkid;
} ITEMIDLIST;
typedef ITEMIDLIST __unaligned *LPITEMIDLIST;
LPITEMIDLIST ILCreateFromPathW(const char*);
ITEMIDLIST*
f()
{
return static_cast<ITEMIDLIST*>(ILCreateFromPathW("nonsense"));
}
The results:
$ cl -c unaligned.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23918 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
unaligned.cpp
$ clang-cl unaligned.cpp -c -fms-compatibility-version=19.00.23918 -m64
unaligned.cpp(13,10): error: static_cast from 'LPITEMIDLIST' (aka '__unaligned
_ITEMIDLIST *') to 'ITEMIDLIST *' (aka '_ITEMIDLIST *'), which are not
related by inheritance, is not allowed
return static_cast<ITEMIDLIST*>(ILCreateFromPathW("nonsense"));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
The actual definitions of all of these types come from <ShTypes.h> and
<ShlObj.h>.
Microsoft's documentation for __unaligned says that it is only accepted on
x86-64 and Itanium, but that it only has an effect on Itanium:
<a href="https://msdn.microsoft.com/en-us/library/ms177389.aspx">https://msdn.microsoft.com/en-us/library/ms177389.aspx</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>