Skip to content

Commit

Permalink
Merge pull request #74 from s-ludwig/fix_deprecation
Browse files Browse the repository at this point in the history
Silence deprecation warning for accessing overlapping pointer data in safe code
  • Loading branch information
l-kramer authored Apr 18, 2024
2 parents c40e23c + fb8bb76 commit 11c3a17
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/taggedalgebraic/taggedunion.d
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ align(commonAlignment!(UnionKindTypes!(UnionFieldEnum!U))) struct TaggedUnion
private {
static if (isUnitType!(FieldTypes[0]) || __VERSION__ < 2072) {
void[Largest!FieldTypes.sizeof] m_data;
@property ref inout(void[Largest!FieldTypes.sizeof]) rawData() inout @safe return { return m_data; }
} else {
union Dummy {
FieldTypes[0] initField;
void[Largest!FieldTypes.sizeof] data;
alias data this;
}
Dummy m_data = { initField: FieldTypes[0].init };
@property ref inout(void[Largest!FieldTypes.sizeof]) rawData() inout @trusted return { return m_data.data; }
}
Kind m_kind;
}
Expand Down Expand Up @@ -319,7 +320,7 @@ align(commonAlignment!(UnionKindTypes!(UnionFieldEnum!U))) struct TaggedUnion
{
if (m_kind != kind) {
destroy(this);
m_data.rawEmplace(value);
this.rawData.rawEmplace(value);
} else {
rawSwap(trustedGet!(FieldTypes[kind]), value);
}
Expand Down Expand Up @@ -373,7 +374,7 @@ align(commonAlignment!(UnionKindTypes!(UnionFieldEnum!U))) struct TaggedUnion
}
}

package @trusted @property ref inout(T) trustedGet(T)() inout { return *cast(inout(T)*)m_data.ptr; }
package @trusted @property ref inout(T) trustedGet(T)() inout { return *cast(inout(T)*)this.rawData.ptr; }
}
}

Expand Down

0 comments on commit 11c3a17

Please sign in to comment.