[llvm-bugs] [Bug 40744] New: [RFE] allow offsetof() in constexpr

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 15 14:03:11 PST 2019


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

            Bug ID: 40744
           Summary: [RFE] allow offsetof() in constexpr
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: stsp at list.ru
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The below examples reject:

struct A {
    char a;
    static constexpr int b = offsetof(A, a);
};

struct A {
    char a;
    B<offsetof(A, a)> b;
};


And there seem to be no easy work-around.
On stackoverflow people suggest the reinterpret_cast-based
solutions, which are illegal in constexpr too.
Is there anything in standard, that makes this code invalid?

-- 
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/20190215/9b70fe66/attachment.html>


More information about the llvm-bugs mailing list