[llvm-bugs] [Bug 47365] New: Can not use a struct type of base containing both enum and protected destructor

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 31 06:33:17 PDT 2020


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

            Bug ID: 47365
           Summary: Can not use a struct type of base containing both enum
                    and protected destructor
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tangyixuan at mail.dlut.edu.cn
                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 following code is accepted by g++, while is rejected by clang++.

$ cat s.cpp

enum class A {
};

struct B {
    A a;
protected:
    ~B() = default;
};

struct C : B {
};

int main(){
    C c{};
}

$ g++ -c s.cpp
success.

$ clang++ -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
ab4627364aefcaac751e757b721b7d07b48a545a)
Target: x86_64-unknown-linux-gnu
Thread model: posix

$ clang++ -c s.cpp

s.cpp:14:9: error: temporary of type 'B' has protected destructor
    C c{};
        ^
s.cpp:7:5: note: declared protected here
    ~B() = default;  
    ^
1 error generated.

-- 
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/20200831/0e79356d/attachment.html>


More information about the llvm-bugs mailing list