Fix compilation with DMD 2.072.0

The following DMD PRs added more rigorous safety checks directly
affecting this project:
* dlang/dmd#5852 (fix Issue 15399 - unaligned pointers are not
  `@safe`) - triggered at line:
  https://github.com/kiith-sa/D-YAML/blob/v0.5.3/source/dyaml/emitter.d#L1011

* dlang/dmd#5940 (Unions may break immutability / unions with
  pointers are un-`@safe` ) - triggered at line:
  https://github.com/kiith-sa/D-YAML/blob/v0.5.3/source/dyaml/event.d#L230

* dlang/dmd#5876 (Casting from `void[]` to `T[]` is erroneously
  considered `@safe`) - triggered at line:
  https://github.com/kiith-sa/D-YAML/blob/v0.5.3/source/dyaml/loader.d#L186

* dlang/dmd#5860 (array.ptr in @safe code may point past end
  of array) - triggered at line:
  https://github.com/kiith-sa/D-YAML/blob/v0.5.3/source/dyaml/zerostring.d#L35
This commit is contained in:
ZombineDev 2016-11-04 02:17:52 +02:00
parent b2ad1b41b3
commit 8d5b75b879
4 changed files with 9 additions and 5 deletions

View file

@ -54,7 +54,7 @@ class EmitterException : YAMLException
private alias EmitterException Error; private alias EmitterException Error;
//Stores results of analysis of a scalar, determining e.g. what scalar style to use. //Stores results of analysis of a scalar, determining e.g. what scalar style to use.
align(4) struct ScalarAnalysis struct ScalarAnalysis
{ {
//Scalar itself. //Scalar itself.
string scalar; string scalar;

View file

@ -227,8 +227,12 @@ Event scalarEvent(const Mark start, const Mark end, const Anchor anchor, const T
result.value = value; result.value = value;
result.startMark = start; result.startMark = start;
result.endMark = end; result.endMark = end;
result.anchor = anchor;
result.tag = tag; () @trusted {
result.anchor = anchor;
result.tag = tag;
}();
result.id = EventID.Scalar; result.id = EventID.Scalar;
result.scalarStyle = style; result.scalarStyle = style;
result.implicit = implicit[0]; result.implicit = implicit[0];

View file

@ -179,7 +179,7 @@ struct Loader
* *
* Throws: YAMLException if yamlData contains data illegal in YAML. * Throws: YAMLException if yamlData contains data illegal in YAML.
*/ */
this(void[] yamlData) @safe this(void[] yamlData) @trusted
{ {
try try
{ {

View file

@ -24,7 +24,7 @@ struct ZeroString(string TypeName)
@disable int opCmp(ref ZeroString); @disable int opCmp(ref ZeroString);
///Construct a string. ///Construct a string.
this(const string str) pure nothrow @safe this(const string str) pure nothrow @trusted
{ {
if(str is null || str == "") if(str is null || str == "")
{ {