Giter VIP home page Giter VIP logo

Comments (7)

zygoloid avatar zygoloid commented on July 2, 2024

Looks like this will need to wait for v2. For this testcase:

struct X { virtual ~X(); };
struct A : virtual X { A(); virtual void f() = 0; ~A(); };
struct Y : A { void f() {} } y;

... Clang emits a reference to _ZN1AD0Ev and to _ZN1AD1Ev when forming the construction vtable for A in Y, so ceasing to emit these symbols would break ABI in practice.

However, we can emit them as symbols with value 0 or something similar (that's what GCC puts in the construction vtable today). __cxa_pure_virtual is almost a good fit here, but in practice the diagnostic it would produce for the case of, say,

A::A() { delete this; }

... doesn't really explain the problem.

from cxx-abi.

zygoloid avatar zygoloid commented on July 2, 2024

See also http://wg21.link/cwg1658, which means that it is no longer correct in general for emission of an abstract class's destructor to emit references to vbase destructors (for instance, a vbase destructor in a class template doesn't necessarily have a point of instantiation in the same translation unit).

from cxx-abi.

rjmccall avatar rjmccall commented on July 2, 2024

I agree with everything you have to say here. Tagging so that we can easily find this when we start adding v2-recommendation sections to the ABI.

from cxx-abi.

zygoloid avatar zygoloid commented on July 2, 2024

So... it turns out that this is valid:

struct B : A {};
void f(B *p) { p->A::~A(); }

... and ends up calling the complete object destructor for A. But that seems like a language bug to me.

from cxx-abi.

rjmccall avatar rjmccall commented on July 2, 2024

It's also necessarily UB, right? So we're not actually obliged to implement it by calling the complete object destructor; we could just call the base constructor (or much worse, of course).

from cxx-abi.

zygoloid avatar zygoloid commented on July 2, 2024

It probably should be UB; I don't think the current language rules say that it is, but we should presumably fix that too :)

from cxx-abi.

rjmccall avatar rjmccall commented on July 2, 2024

Well, we can get started on implementing a runtime global dictionary of object kinds by address if the committee insists. :)

from cxx-abi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.