[llvm-bugs] [Bug 35327] New: constexpr initialization with reinterpret_cast

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 16 01:24:35 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=35327

            Bug ID: 35327
           Summary: constexpr initialization with reinterpret_cast
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ivan.donchevskii at qt.io
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

By standard it should not be possible but msvc (at least 2015 and 2017)
compiles fine with that. clang-cl fails trying to compile the same code.

Can be noticed in offsetof calls or similar declarations.

Example:

#define my_offsetof(s,m) ((int)&reinterpret_cast<char const
volatile&>((((s*)0)->m)))
struct Foo { int Bar;};
static constexpr int offset= my_offsetof(Foo, Bar);

This code compiles fine with cl but fails with clang-cl

-- 
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/20171116/6d5adb60/attachment.html>


More information about the llvm-bugs mailing list