C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Give Microsoft N years to change their ABI

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Thu, 14 Nov 2024 16:47:51 +0000
What you are trying to do is conceptually misformed, not just from a Cpp perspective, but from a computer science perspective.
It makes absolutely no sense that you should be able to extract a pointer to a vtable at offset 0 from any random address you can possibly have.
You either know what is at the address, or you don't. Those are your 2 options. There's no amount of runtime bodging that is going to save this much less even be desirable.
This is just out of the fact that bits are just interchangeable in regards to usage, if you don't know what they are being used for how would you know what they are being used for?


________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]>
Sent: Thursday, November 14, 2024 5:22:15 PM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Subject: Re: [std-proposals] Give Microsoft N years to change their ABI

On Thu, Nov 14, 2024 at 1:44 PM Bo Persson wrote:
>
> The standard contains the rules that compiler manufacturers can agree
> upon. If you add rules they don't like, or cannot implement because
> their other customers don't want it, they will just be "almost
> compliant" with the next release.
>
> For example, the C++ standard removed trigraphs which was "only" used by
> IBM customers using EBCDIC encoding. So this is now a "language
> extension", still available in IBM's compilers.


If Microsoft are interested in doing this, they could do it in 3 steps:

Step 1: Microsoft adds a new keyword "__vptr0" which can be used as follows:

    struct __vptr0 MyClass : SomeBaseClass { virtual ~MyClass(void) =
default; };

Any class which is marked with the "__vptr0" keyword would have its
VTable pointer at offset 0.
There would also have to be a keyword "__vptrLegacy" in order to use
Microsoft's old way of doing it.

Step 2: Microsoft adds a new compiler switch "/vptr:" which can be
used as follows:

    cl.exe main.cpp /vptr:0
    cl.exe main.cpp /vptr:legacy

 So if you use use the former command line option, every class will
have its VTable at offset 0. If you use the latter command line
option, every class will have its VTable in the old legacy Microsoft
position. The default will be "/vptr:legacy".

Step 3: Perhaps 5 or 10 year from now, Microsoft changes the
default command line switch from "/vptr:legacy" to "/vptr:0".

And then the whole C++ community is no longer burdened by Microsoft's
implementation of VTables.
--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2024-11-14 16:48:03