Date: Thu, 14 Nov 2024 16:21:57 +0000
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.
>
> 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.
Received on 2024-11-14 16:22:09