Hello,
Browsing the code, I noticed that D_RW macro (for compilers other than microsoft visual) is defined as:
#define DIRECT_RW(o) (\
{__typeof__(o) _o; _o._type = NULL; (void)_o;\
(__typeof__(*(o)._type) *)pmemobj_direct((o).oid); })
While D_RO is just:
#define DIRECT_RO(o) ((const __typeof__(*(o)._type) *)pmemobj_direct((o).oid))
Now my question is: what is the purpose of the part: __typeof__(o) _o; _o._type = NULL; (void)_o; in D_RW macro?
Would it not be just be always optimized out?
What would go wrong if D_RW were implemented just as:
#define DIRECT_RW(o) ((__typeof__(*(o)._type) *)pmemobj_direct((o).oid))
thus avoiding non-standard ({ … }) syntax and seemingly redundant statements?
Plus: do apps with no optimization (-O0) create the _o and execute the assignment _o._type = NULL?
Link to github:
Regards,
Jan