[llvm-bugs] [Bug 43762] New: Invalid active union member change

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 22 11:29:50 PDT 2019


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

            Bug ID: 43762
           Summary: Invalid active union member change
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: n at ndor.email
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

The following should not compile:

class A {
public:
    int x = 1;
    constexpr virtual int f() = 0;
};

class B : public A {
public:
    int y = 1;
    constexpr virtual int f() override { return 1; }
};


union U {
    int n;
    B b;
};

constexpr int test() {
    U u { .n = 5 };
    u.b.x = 10;
    return u.b.f();
}

static_assert(test());

-- 
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/20191022/8bfa4b85/attachment.html>


More information about the llvm-bugs mailing list