schveiguy / io

Core I/O functionality
Boost Software License 1.0
25 stars 9 forks source link

std.io.driver.globalDriver(): Fix invalid reinterpret-cast #30

Closed kinke closed 5 years ago

schveiguy commented 5 years ago

Why is the cast invalid? It's changing from immutable Driver * to shared(Driver)*? In fact, I'd say the new cast is not valid.

kinke commented 5 years ago

Reinterpreting an interface reference as class reference doesn't offset as it should, because the cas() implementation then treats that reference as regular SyncDriver class reference, and offsets that back to the interface pointer (in a CAS implementation fixed in LDC 1.18).

schveiguy commented 5 years ago

It should all be in the realm of interface, there are no classes here. _syncDriver should already be adjusted as it's typed as immutable Driver. Maybe LDC is doing something too clever here?

schveiguy commented 5 years ago

Crap, I misread what was being deleted and added. Yes, your new code should be right.

schveiguy commented 5 years ago

I'm going to put your code in with #28 instead of here, because the current CI doesn't test properly (yet), it uses the latest DMD which has a broken cas.

schveiguy commented 5 years ago

Actually, I just decided to pull it. It's obviously correct. And I'd like to keep #28 focused on adding the meson build (even though it does technically also fix the normal build).