[llvm-bugs] [Bug 30578] New: 64-bit clang-cl does not discard the __unaligned attribute on pointers when casting
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Sep 30 08:57:52 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=30578
Bug ID: 30578
Summary: 64-bit clang-cl does not discard the __unaligned
attribute on pointers when casting
Product: new-bugs
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: froydnj at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
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:
https://msdn.microsoft.com/en-us/library/ms177389.aspx
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160930/318aee3c/attachment.html>
More information about the llvm-bugs
mailing list