[LLVMbugs] [Bug 12116] New: Allow reinterpret_cast in constant expressions in microsoft mode
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Feb 28 11:11:26 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=12116
Bug #: 12116
Summary: Allow reinterpret_cast in constant expressions in
microsoft mode
Product: clang
Version: unspecified
Platform: PC
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: nicolasweber at gmx.de
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
When compiling ms headers with -nobuiltininc, clang picks up offsetof() from
msvc's stddef.h (
http://msdn.microsoft.com/en-us/library/dz4y9b9a(v=vs.80).aspx ). If it's used
with chrome's STATIC_ASSERT macro, clang complains about "reinterpret_cast not
allowed in constant expressions".
I came up with an offsetof() macro that exhibits the same error:
hummer:clang thakis$ cat test.cc
#define offsetof(s,m) \
(long)(void*)&((reinterpret_cast<s*>(0)->m))
template <bool>
struct GpuCompileAssert {
};
struct SetToken {
int a, token;
};
GpuCompileAssert<(bool(offsetof(SetToken, token) == 4))> foo;
hummer:clang thakis$ ../../Release+Asserts/bin/clang -c test.cc -fms-extensions
-fms-compatibility
here4!
here3!
test.cc:12:18: error: non-type template argument of type 'bool' is not an
integral constant expression
GpuCompileAssert<(bool(offsetof(SetToken, token) == 4))> foo;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.cc:12:24: note: cast which performs the conversions of a reinterpret_cast
is not allowed in a constant expression
GpuCompileAssert<(bool(offsetof(SetToken, token) == 4))> foo;
^
test.cc:2:3: note: expanded from macro 'offsetof'
(long)(void*)&((reinterpret_cast<s*>(0)->m))
^
1 error generated.
We should allow reinterpret_cast<>()s in constant expressions in microsoft
mode.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list