"explicit cast to derived class" and "64/32 bit processes sharing" #33

Merged
merged 2 commits into from Jan 19, 2017

Conversation

Projects
None yet
2 participants
Contributor

treh commented Jan 16, 2017

See individual commits for details.

treh added some commits Jan 4, 2017

@treh treh Enable explicit construction of offset_ptr<Derived> from offset_ptr<B…
…ase>

With 'enable_if<!is_convertible && is_constructible>' and 'explicit',
care is taken to behave just as 'normal' pointers.
892e541
@treh treh Restore possibility to communicate between 32 and 64 bit processes us…
…ing 64 bit offsets

If the pointed adress is 128 bytes lower than 'this', we have

(a) 32bit uintptr_t, 32bit OffsetType: offset = 0x        ffffff80
(b) 64bit uintptr_t, 64bit OffsetType: offset = 0xffffffffffffff80
(c) 32bit uintptr_t, 64bit OffsetType: offset = 0x00000000ffffff80

If we read (c) from an 64bit process, it gets interpreted
as 4294967232 bytes forward rather than 128 bytes backward.

This commit solves the problem by ajusting the offset representation of (c)
to match (b).
For the 32bit process itself (c) this makes no difference, as the most
significant 4 bytes get truncated anyway when convertig to a pointer.

Note: For the default OffsetType=uintptr_t this change is only
syntactical.
f78a2e2

@igaztanaga igaztanaga merged commit f78a2e2 into boostorg:develop Jan 19, 2017

Collaborator

igaztanaga commented Jan 19, 2017

Many thanks for the patch. The compatibility between 32 and 64 bit processes was solved in a very elegant way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment