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

            Bug ID: 51689
           Summary: Clang introduces invalid padding for empty base
                    classes
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: CUDA
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Following up on issues reported in
https://github.com/illuhad/hipSYCL/issues/620#issuecomment-908400489 we tracked
the issue down to an invalid struct layout with multiple empty base classes.

https://godbolt.org/z/xoa9P38vW

The example introduces invalid padding on Windows hosts, thus leading to issues
when using the `has_wrong_size` class in CUDA or similar contexts, where the
layout of the class is of high importance.

Note that the device code has no padding and would compile fine.

#include <stdint.h>

class test0{};
class test1{};
class test2{public: uint64_t s;};

class works : public test0,  public test2{};

static_assert(__builtin_offsetof(works, s) == 0, "offset");

static_assert(sizeof(works) == sizeof(uint64_t), "size wrong");

class has_wrong_size : public test0, public test1, public test2{};
//#ifdef __CUDACC__ // is fine on CUDA
static_assert(__builtin_offsetof(has_wrong_size, s) == 0, "offset");

static_assert(sizeof(has_wrong_size) == sizeof(uint64_t), "size wrong");
//#endif

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to