Tuesday, June 9, 2020

Digest for comp.lang.c++@googlegroups.com - 25 updates in 3 topics

Richard Damon <Richard@Damon-Family.org>: Jun 08 09:54PM -0400

On 6/8/20 12:54 PM, Scott Newman wrote:
> will take the this pointer.
> There might be implementations where this won't work, but
> currently there isn't any.
 
One issue with this, is that depending on the exact inheritance
hierarchy, it can well be that the entry for the given function doesn't
point directly to the function, but to a 'thunk' that adjusts the object
pointer. Also, it isn't always a matter of THE vtable, but A vtable or
THE vtableS (multiple inheritance creates multiple vtables)
Paavo Helde <eesnimi@osa.pri.ee>: Jun 09 07:11AM +0300

09.06.2020 00:57 James Kuyper kirjutas:
 
>> What makes you think vtable is per-object?
 
> I think what he means is that each object can contain a pointer to a
> different vtable.
 
In that case the objects would belong to different classes. And voila,
static data members defined in different classes would be different as well!
 
> It's the pointer, not the vtable, which is per-object.
 
OP wanted to modify a slot in a vtable.
 
A vtable is a class-specific data structure residing in a single place
in the program memory space (unless duplicated and/or modified by
optimizations/thunks/dynamic libraries support, and unless bypassed by
optimizations).
 
A static data member is a class-specific data structure residing in a
single place in the program memory space, guaranteed.
Scott Newman <scott69@gmail.com>: Jun 09 09:34AM +0200

> What makes you think vtable is per-object?
 
Show me the the code you have in mind.
Scott Newman <scott69@gmail.com>: Jun 09 09:46AM +0200

>>      while( !stop.load( memory_order_relaxed );
>> I think the first one is more readable.
 
> EVERYTHING YOU SAY IS WRONG.
 
Ok, just because you say it.
Ian Collins <ian-news@hotmail.com>: Jun 09 07:52PM +1200

On 09/06/2020 08:58, David Brown wrote:
>> space for each function. If you modify the vtable, this wouldn't need
>> additional space.
 
> You must surely be trolling.
 
You took your time!
 
--
Ian.
"Öö Tiib" <ootiib@hot.ee>: Jun 09 01:09AM -0700

On Tuesday, 9 June 2020 10:46:41 UTC+3, Scott Newman wrote:
> >> I think the first one is more readable.
 
> > EVERYTHING YOU SAY IS WRONG.
 
> Ok, just because you say it.
 
No. By C++ standard since 2011 it is data race and so all bets off
undefined behavior, demons out from your nose included but not
guaranteed.
 
It may be some pre-C++11 compiler or some modern that specially
documents extensions but you utterly failed to mention any of it
so all you wrote was wrong.
Scott Newman <scott69@gmail.com>: Jun 09 10:20AM +0200

> No. By C++ standard since 2011 it is data race and so all bets off
> undefined behavior, demons out from your nose included but not
> guaranteed.
 
The standard doesn't matter.
We were talking about the compatibility of different implementations.
Scott Newman <scott69@gmail.com>: Jun 09 10:21AM +0200

Here, that's industrial-strength 100% portable code:
 
#include <iostream>
 
using namespace std;
 
#if defined _MSC_VER
#define CC cdecl
#else
#define CC

No comments: