[llvm-bugs] [Bug 37015] New: MS __declspec(empty_bases) generates error with virtual inheritance

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 5 06:30:05 PDT 2018


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

            Bug ID: 37015
           Summary: MS __declspec(empty_bases) generates error with
                    virtual inheritance
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: soumi.manna at intel.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

The below program fails to generate correct size of Derived class when
__declspec(empty_bases) is applied on virtual inheritance. Microsoft compiler
compiles the test. 

bash-3.2$ cat test.cpp
struct Empty1 {};
struct Empty2 {};

struct __declspec(empty_bases) Derived : virtual Empty2
{
};
static_assert(sizeof(Derived) == 8, "Derived should be 8 byte");

struct Derived1 : virtual Derived, virtual Empty1
{
};
static_assert(sizeof(Derived1) == 16, "Derived1 should be 16 byte");


bash-3.2$ clang -c test.cpp
test.cpp:12:1: error: static_assert failed "Derived1 should be 16 byte"
static_assert(sizeof(Derived1) == 16, "Derived1 should be 16 byte");
^             ~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

bash-3.2$ cl -c test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp

-- 
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/20180405/80ebc113/attachment-0001.html>


More information about the llvm-bugs mailing list