summaryrefslogtreecommitdiff
path: root/libphobos/libdruntime
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2023-07-10 03:07:41 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2023-07-10 03:13:00 +0200
commit0cafc3b6272d1dd738e8d7e66e1d8741e08f74d3 (patch)
tree8c549ddd4b93c78f44959d47a4956837022a5cf1 /libphobos/libdruntime
parentd41a57c46df6f8f7dae0c0a8b349e734806a837b (diff)
d: Merge upstream dmd, druntime 17ccd12af3, phobos 8d3800bee.
D front-end changes: - Import dmd v2.104.0. - Assignment-style syntax is now allowed for `alias this'. - Overloading `extern(C)' functions is now an error. D runtime changes: - Import druntime v2.104.0. Phobos changes: - Import phobos v2.104.0. - Better static assert messages when instantiating `std.algorithm.iteration.permutations' with wrong inputs. - Added `std.system.instructionSetArchitecture' and `std.system.ISA'. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 17ccd12af3. * dmd/VERSION: Bump version to v2.104.0. * Make-lang.in (D_FRONTEND_OBJS): Rename d/apply.o to d/postordervisitor.o. * d-codegen.cc (make_location_t): Update for new front-end interface. (build_filename_from_loc): Likewise. (build_assert_call): Likewise. (build_array_bounds_call): Likewise. (build_bounds_index_condition): Likewise. (build_bounds_slice_condition): Likewise. (build_frame_type): Likewise. (get_frameinfo): Likewise. * d-diagnostic.cc (d_diagnostic_report_diagnostic): Likewise. * decl.cc (build_decl_tree): Likewise. (start_function): Likewise. * expr.cc (ExprVisitor::visit (NewExp *)): Replace code generation of `new pointer' with front-end lowering. * runtime.def (NEWITEMT): Remove. (NEWITEMIT): Remove. * toir.cc (IRVisitor::visit (LabelStatement *)): Update for new front-end interface. * typeinfo.cc (check_typeinfo_type): Likewise. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 17ccd12af3. * src/MERGE: Merge upstream phobos 8d3800bee. gcc/testsuite/ChangeLog: * gdc.dg/asm4.d: Update test.
Diffstat (limited to 'libphobos/libdruntime')
-rw-r--r--libphobos/libdruntime/MERGE2
-rw-r--r--libphobos/libdruntime/__builtins.di3
-rw-r--r--libphobos/libdruntime/core/atomic.d2
-rw-r--r--libphobos/libdruntime/core/internal/string.d8
-rw-r--r--libphobos/libdruntime/core/internal/util/array.d16
-rw-r--r--libphobos/libdruntime/core/lifetime.d197
-rw-r--r--libphobos/libdruntime/core/stdc/assert_.d31
-rw-r--r--libphobos/libdruntime/object.d5
-rw-r--r--libphobos/libdruntime/rt/cast_.d20
-rw-r--r--libphobos/libdruntime/rt/lifetime.d136
10 files changed, 235 insertions, 185 deletions
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 95ea67d789b..1cff48a7b2a 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-28a3b24c2e45de39cd3df528142fd06b6456e8fd
+17ccd12af386543c0b9935bf7e0a8e701b903105
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
diff --git a/libphobos/libdruntime/__builtins.di b/libphobos/libdruntime/__builtins.di
index 1c490358904..74147a095cd 100644
--- a/libphobos/libdruntime/__builtins.di
+++ b/libphobos/libdruntime/__builtins.di
@@ -67,8 +67,7 @@ version (DigitalMars)
ushort __builtin_bswap16()(ushort value)
{
- import core.bitop;
- return core.bitop.byteswap(value);
+ return cast(ushort) (((value >> 8) & 0xFF) | ((value << 8) & 0xFF00U));
}
uint __builtin_bswap32()(uint value)
diff --git a/libphobos/libdruntime/core/atomic.d b/libphobos/libdruntime/core/atomic.d
index 1fba06cc021..5a7d00c38db 100644
--- a/libphobos/libdruntime/core/atomic.d
+++ b/libphobos/libdruntime/core/atomic.d
@@ -162,7 +162,7 @@ void atomicStore(MemoryOrder ms = MemoryOrder.seq, T, V)(ref shared T val, V new
}
/// Ditto
-void atomicStore(MemoryOrder ms = MemoryOrder.seq, T, V)(ref shared T val, shared V newval) pure nothrow @nogc @trusted
+void atomicStore(MemoryOrder ms = MemoryOrder.seq, T, V)(ref shared T val, auto ref shared V newval) pure nothrow @nogc @trusted
if (is(T == class))
{
static assert (is (V : T), "Can't assign `newval` of type `shared " ~ V.stringof ~ "` to `shared " ~ T.stringof ~ "`.");
diff --git a/libphobos/libdruntime/core/internal/string.d b/libphobos/libdruntime/core/internal/string.d
index e09bba4707b..7bb319ecfa5 100644
--- a/libphobos/libdruntime/core/internal/string.d
+++ b/libphobos/libdruntime/core/internal/string.d
@@ -152,7 +152,7 @@ T[] signedToTempString(uint radix = 10, bool upperCase = false, T)(long value, r
if (neg)
{
// about to do a slice without a bounds check
- auto trustedSlice(return scope char[] r) @trusted { assert(r.ptr > buf.ptr); return (r.ptr-1)[0..r.length+1]; }
+ auto trustedSlice(return scope T[] r) @trusted { assert(r.ptr > buf.ptr); return (r.ptr-1)[0..r.length+1]; }
r = trustedSlice(r);
r[0] = '-';
}
@@ -190,6 +190,12 @@ unittest
assert(long.max.signedToTempString(buf) == "9223372036854775807");
assert(long.min.signedToTempString(buf) == "-9223372036854775808");
+ wchar[65] wbuf = void;
+ assert(1.signedToTempString(wbuf) == "1"w);
+
+ dchar[65] dbuf = void;
+ assert(1.signedToTempString(dbuf) == "1"d);
+
// use stack allocated struct version
assert(0.signedToTempString() == "0");
assert(1.signedToTempString == "1");
diff --git a/libphobos/libdruntime/core/internal/util/array.d b/libphobos/libdruntime/core/internal/util/array.d
index 6136cfef17d..066ee7e72db 100644
--- a/libphobos/libdruntime/core/internal/util/array.d
+++ b/libphobos/libdruntime/core/internal/util/array.d
@@ -26,14 +26,6 @@ private char[] errorMessage(Args...)(scope const(char*) format,
@safe /* pure dmd @@@BUG11461@@@ */ nothrow:
-void enforceTypedArraysConformable(T)(const char[] action,
- const T[] a1, const T[] a2, const bool allowOverlap = false)
-{
- _enforceSameLength(action, a1.length, a2.length);
- if (!allowOverlap)
- _enforceNoOverlap(action, arrayToPtr(a1), arrayToPtr(a2), T.sizeof * a1.length);
-}
-
void enforceRawArraysConformable(const char[] action, const size_t elementSize,
const void[] a1, const void[] a2, const bool allowOverlap = false)
{
@@ -76,14 +68,6 @@ private void _enforceNoOverlap(const char[] action,
assert(0, msg);
}
-void enforceTypedArraysConformableNogc(T)(const char[] action,
- const T[] a1, const T[] a2, const bool allowOverlap = false)
-{
- _enforceSameLengthNogc(action, a1.length, a2.length);
- if (!allowOverlap)
- _enforceNoOverlapNogc(action, arrayToPtr(a1), arrayToPtr(a2), T.sizeof * a1.length);
-}
-
void enforceRawArraysConformableNogc(const char[] action, const size_t elementSize,
const void[] a1, const void[] a2, const bool allowOverlap = false)
{
diff --git a/libphobos/libdruntime/core/lifetime.d b/libphobos/libdruntime/core/lifetime.d
index 5e339c041d1..ae047cb730e 100644
--- a/libphobos/libdruntime/core/lifetime.d
+++ b/libphobos/libdruntime/core/lifetime.d
@@ -2777,6 +2777,70 @@ if (is(T == class))
return cast(T) p;
}
+/**
+ * TraceGC wrapper around $(REF _d_newclassT, core,lifetime).
+ */
+T _d_newclassTTrace(T)(string file, int line, string funcname) @trusted
+{
+ version (D_TypeInfo)
+ {
+ import core.internal.array.utils : TraceHook, gcStatsPure, accumulatePure;
+ mixin(TraceHook!(T.stringof, "_d_newclassT"));
+
+ return _d_newclassT!T();
+ }
+ else
+ assert(0, "Cannot create new class if compiling without support for runtime type information!");
+}
+
+/**
+ * Allocate an initialized non-array item.
+ *
+ * This is an optimization to avoid things needed for arrays like the __arrayPad(size).
+ * Used to allocate struct instances on the heap.
+ *
+ * ---
+ * struct Sz {int x = 0;}
+ * struct Si {int x = 3;}
+ *
+ * void main()
+ * {
+ * new Sz(); // uses zero-initialization
+ * new Si(); // uses Si.init
+ * }
+ * ---
+ *
+ * Returns:
+ * newly allocated item
+ */
+T* _d_newitemT(T)() @trusted
+{
+ import core.internal.lifetime : emplaceInitializer;
+ import core.internal.traits : hasElaborateDestructor, hasIndirections;
+ import core.memory : GC;
+
+ auto flags = !hasIndirections!T ? GC.BlkAttr.NO_SCAN : GC.BlkAttr.NONE;
+ immutable tiSize = hasElaborateDestructor!T ? size_t.sizeof : 0;
+ immutable itemSize = T.sizeof;
+ immutable totalSize = itemSize + tiSize;
+ if (tiSize)
+ flags |= GC.BlkAttr.STRUCTFINAL | GC.BlkAttr.FINALIZE;
+
+ auto blkInfo = GC.qalloc(totalSize, flags, null);
+ auto p = blkInfo.base;
+
+ if (tiSize)
+ {
+ // The GC might not have cleared the padding area in the block.
+ *cast(TypeInfo*) (p + (itemSize & ~(size_t.sizeof - 1))) = null;
+ *cast(TypeInfo*) (p + blkInfo.size - tiSize) = cast() typeid(T);
+ }
+
+ emplaceInitializer(*(cast(T*) p));
+
+ return cast(T*) p;
+}
+
// Test allocation
@safe unittest
{
@@ -2805,15 +2869,134 @@ if (is(T == class))
}
}
-T _d_newclassTTrace(T)(string file, int line, string funcname) @trusted
+// Test allocation
+@safe unittest
+{
+ struct S { }
+ S* s = _d_newitemT!S();
+
+ assert(s !is null);
+}
+
+// Test initializers
+@safe unittest
{
- version (D_TypeInfo)
{
- import core.internal.array.utils: TraceHook, gcStatsPure, accumulatePure;
- mixin(TraceHook!(T.stringof, "_d_newclassT"));
+ // zero-initialization
+ struct S { int x, y; }
+ S* s = _d_newitemT!S();
- return _d_newclassT!T();
+ assert(s.x == 0);
+ assert(s.y == 0);
+ }
+ {
+ // S.init
+ struct S { int x = 2, y = 3; }
+ S* s = _d_newitemT!S();
+
+ assert(s.x == 2);
+ assert(s.y == 3);
+ }
+}
+
+// Test GC attributes
+version (CoreUnittest)
+{
+ struct S1
+ {
+ int x = 5;
+ }
+ struct S2
+ {
+ int x;
+ this(int x) { this.x = x; }
+ }
+ struct S3
+ {
+ int[4] x;
+ this(int x) { this.x[] = x; }
+ }
+ struct S4
+ {
+ int *x;
+ }
+
+}
+@system unittest
+{
+ import core.memory : GC;
+
+ auto s1 = new S1;
+ assert(s1.x == 5);
+ assert(GC.getAttr(s1) == GC.BlkAttr.NO_SCAN);
+
+ auto s2 = new S2(3);
+ assert(s2.x == 3);
+ assert(GC.getAttr(s2) == GC.BlkAttr.NO_SCAN);
+
+ auto s3 = new S3(1);
+ assert(s3.x == [1, 1, 1, 1]);
+ assert(GC.getAttr(s3) == GC.BlkAttr.NO_SCAN);
+ debug(SENTINEL) {} else
+ assert(GC.sizeOf(s3) == 16);
+
+ auto s4 = new S4;
+ assert(s4.x == null);
+ assert(GC.getAttr(s4) == 0);
+}
+
+// Test struct finalizers exception handling
+debug(SENTINEL) {} else
+@system unittest
+{
+ import core.memory : GC;
+
+ bool test(E)()
+ {
+ import core.exception;
+ static struct S1
+ {
+ E exc;
+ ~this() { throw exc; }
+ }
+
+ bool caught = false;
+ S1* s = new S1(new E("test onFinalizeError"));
+ try
+ {
+ GC.runFinalizers((cast(char*)(typeid(S1).xdtor))[0 .. 1]);
+ }
+ catch (FinalizeError err)
+ {
+ caught = true;
+ }
+ catch (E)
+ {
+ }
+ GC.free(s);
+ return caught;
+ }
+
+ assert(test!Exception);
+ import core.exception : InvalidMemoryOperationError;
+ assert(!test!InvalidMemoryOperationError);
+}
+
+version (D_ProfileGC)
+{
+ /**
+ * TraceGC wrapper around $(REF _d_newitemT, core,lifetime).
+ */
+ T* _d_newitemTTrace(T)(string file, int line, string funcname) @trusted
+ {
+ version (D_TypeInfo)
+ {
+ import core.internal.array.utils : TraceHook, gcStatsPure, accumulatePure;
+ mixin(TraceHook!(T.stringof, "_d_newitemT"));
+
+ return _d_newitemT!T();
+ }
+ else
+ assert(0, "Cannot create new `struct` if compiling without support for runtime type information!");
}
- else
- assert(0, "Cannot create new class if compiling without support for runtime type information!");
}
diff --git a/libphobos/libdruntime/core/stdc/assert_.d b/libphobos/libdruntime/core/stdc/assert_.d
index fc9402f6051..a8909e26126 100644
--- a/libphobos/libdruntime/core/stdc/assert_.d
+++ b/libphobos/libdruntime/core/stdc/assert_.d
@@ -12,7 +12,6 @@
/****************************
* These are the various functions called by the assert() macro.
- * They are all noreturn functions, although D doesn't have a specific attribute for that.
*/
module core.stdc.assert_;
@@ -36,7 +35,7 @@ version (CRuntime_DigitalMars)
/***
* Assert failure function in the Digital Mars C library.
*/
- void _assert(const(void)* exp, const(void)* file, uint line);
+ noreturn _assert(const(void)* exp, const(void)* file, uint line);
}
else version (CRuntime_Microsoft)
{
@@ -44,37 +43,37 @@ else version (CRuntime_Microsoft)
* Assert failure function in the Microsoft C library.
* `_assert` is not in assert.h, but it is in the library.
*/
- void _wassert(const(wchar)* exp, const(wchar)* file, uint line);
+ noreturn _wassert(const(wchar)* exp, const(wchar)* file, uint line);
///
- void _assert(const(char)* exp, const(char)* file, uint line);
+ noreturn _assert(const(char)* exp, const(char)* file, uint line);
}
else version (Darwin)
{
/***
* Assert failure function in the Darwin C library.
*/
- void __assert_rtn(const(char)* func, const(char)* file, uint line, const(char)* exp);
+ noreturn __assert_rtn(const(char)* func, const(char)* file, uint line, const(char)* exp);
}
else version (FreeBSD)
{
/***
* Assert failure function in the FreeBSD C library.
*/
- void __assert(const(char)* exp, const(char)* file, uint line);
+ noreturn __assert(const(char)* exp, const(char)* file, uint line, const(char)* exp);
}
else version (NetBSD)
{
/***
* Assert failure function in the NetBSD C library.
*/
- void __assert(const(char)* file, int line, const(char)* exp);
+ noreturn __assert(const(char)* file, int line, const(char)* exp);
}
else version (OpenBSD)
{
/***
* Assert failure function in the OpenBSD C library.
*/
- void __assert(const(char)* file, int line, const(char)* exp);
+ noreturn __assert(const(char)* file, int line, const(char)* exp);
///
void __assert2(const(char)* file, int line, const(char)* func, const(char)* exp);
}
@@ -83,37 +82,37 @@ else version (DragonFlyBSD)
/***
* Assert failure function in the DragonFlyBSD C library.
*/
- void __assert(const(char)* exp, const(char)* file, uint line);
+ noreturn __assert(const(char)* exp, const(char)* file, uint line, const(char)* exp);
}
else version (CRuntime_Glibc)
{
/***
* Assert failure functions in the GLIBC library.
*/
- void __assert(const(char)* exp, const(char)* file, uint line);
+ noreturn __assert(const(char)* exp, const(char)* file, uint line);
///
- void __assert_fail(const(char)* exp, const(char)* file, uint line, const(char)* func);
+ noreturn __assert_fail(const(char)* exp, const(char)* file, uint line, const(char)* func);
///
- void __assert_perror_fail(int errnum, const(char)* file, uint line, const(char)* func);
+ noreturn __assert_perror_fail(int errnum, const(char)* file, uint line, const(char)* func);
}
else version (CRuntime_Bionic)
{
- void __assert(const(char)* __file, int __line, const(char)* __msg);
+ noreturn __assert(const(char)* __file, int __line, const(char)* __msg);
}
else version (CRuntime_Musl)
{
/***
* Assert failure function in the Musl C library.
*/
- void __assert_fail(const(char)* exp, const(char)* file, uint line, const(char)* func);
+ noreturn __assert_fail(const(char)* exp, const(char)* file, uint line, const(char)* func);
}
else version (CRuntime_UClibc)
{
- void __assert(const(char)* exp, const(char)* file, uint line, const(char)* func);
+ noreturn __assert(const(char)* exp, const(char)* file, uint line, const(char)* func);
}
else version (Solaris)
{
- void __assert_c99(const(char)* exp, const(char)* file, uint line, const(char)* func);
+ noreturn __assert_c99(const(char)* exp, const(char)* file, uint line, const(char)* func);
}
else
{
diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d
index 610cb7a30a1..337eabf64db 100644
--- a/libphobos/libdruntime/object.d
+++ b/libphobos/libdruntime/object.d
@@ -527,7 +527,8 @@ private extern(C) void _d_setSameMutex(shared Object ownee, shared Object owner)
void setSameMutex(shared Object ownee, shared Object owner)
{
- _d_setSameMutex(ownee, owner);
+ import core.atomic : atomicLoad;
+ _d_setSameMutex(atomicLoad(ownee), atomicLoad(owner));
}
@system unittest
@@ -4532,6 +4533,7 @@ version (D_ProfileGC)
{
public import core.internal.array.appending : _d_arrayappendTTrace;
public import core.internal.array.concatenation : _d_arraycatnTXTrace;
+ public import core.lifetime : _d_newitemTTrace;
}
public import core.internal.array.appending : _d_arrayappendcTXImpl;
public import core.internal.array.comparison : __cmp;
@@ -4560,6 +4562,7 @@ public import core.lifetime : _d_delstructImpl;
public import core.lifetime : _d_newThrowable;
public import core.lifetime : _d_newclassT;
public import core.lifetime : _d_newclassTTrace;
+public import core.lifetime : _d_newitemT;
public @trusted @nogc nothrow pure extern (C) void _d_delThrowable(scope Throwable);
diff --git a/libphobos/libdruntime/rt/cast_.d b/libphobos/libdruntime/rt/cast_.d
index 1604510b427..925599e0159 100644
--- a/libphobos/libdruntime/rt/cast_.d
+++ b/libphobos/libdruntime/rt/cast_.d
@@ -117,22 +117,6 @@ int _d_isbaseof2(scope ClassInfo oc, scope const ClassInfo c, scope ref size_t o
int _d_isbaseof(scope ClassInfo oc, scope const ClassInfo c) @safe
{
- if (areClassInfosEqual(oc, c))
- return true;
-
- do
- {
- if (oc.base && areClassInfosEqual(oc.base, c))
- return true;
-
- foreach (iface; oc.interfaces)
- {
- if (areClassInfosEqual(iface.classinfo, c) || _d_isbaseof(iface.classinfo, c))
- return true;
- }
-
- oc = oc.base;
- } while (oc);
-
- return false;
+ size_t offset = 0;
+ return _d_isbaseof2(oc, c, offset);
}
diff --git a/libphobos/libdruntime/rt/lifetime.d b/libphobos/libdruntime/rt/lifetime.d
index a37541bf01f..40fa3e00b45 100644
--- a/libphobos/libdruntime/rt/lifetime.d
+++ b/libphobos/libdruntime/rt/lifetime.d
@@ -676,7 +676,7 @@ Params:
ti = `TypeInfo` of array type
arr = array to shrink. Its `.length` is element length, not byte length, despite `void` type
*/
-extern(C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) /+nothrow+/
+extern(C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) nothrow
{
// note, we do not care about shared. We are setting the length no matter
// what, so no lock is required.
@@ -701,7 +701,17 @@ extern(C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) /+nothrow+/
{
auto oldsize = __arrayAllocLength(info, tinext);
if (oldsize > cursize)
- finalize_array(arr.ptr + cursize, oldsize - cursize, sti);
+ {
+ try
+ {
+ finalize_array(arr.ptr + cursize, oldsize - cursize, sti);
+ }
+ catch (Exception e)
+ {
+ import core.exception : onFinalizeError;
+ onFinalizeError(sti, e);
+ }
+ }
}
}
// Note: Since we "assume" the append is safe, it means it is not shared.
@@ -1148,25 +1158,8 @@ extern (C) void[] _d_newarraymiTX(const TypeInfo ti, size_t[] dims) @weak
}
/**
-Allocate an uninitialized non-array item.
-
-This is an optimization to avoid things needed for arrays like the __arrayPad(size).
-
-- `_d_newitemU` leaves the item uninitialized
-- `_d_newitemT` zero initializes the item
-- `_d_newitemiT` uses a non-zero initializer from `TypeInfo`
-
-Used to allocate struct instances on the heap.
----
-struct Sz {int x = 0;}
-struct Si {int x = 3;}
-
-void main()
-{
- new Sz(); // _d_newitemT(typeid(Sz))
- new Si(); // _d_newitemiT(typeid(Si))
-}
----
+Non-template version of $(REF _d_newitemT, core,lifetime) that does not perform
+initialization. Needed for $(REF allocEntry, rt,aaA).
Params:
_ti = `TypeInfo` of item to allocate
@@ -1196,26 +1189,6 @@ extern (C) void* _d_newitemU(scope const TypeInfo _ti) pure nothrow @weak
return p;
}
-/// ditto
-extern (C) void* _d_newitemT(const TypeInfo _ti) pure nothrow @weak
-{
- import core.stdc.string;
- auto p = _d_newitemU(_ti);
- memset(p, 0, _ti.tsize);
- return p;
-}
-
-/// Same as above, for item with non-zero initializer.
-extern (C) void* _d_newitemiT(const TypeInfo _ti) pure nothrow @weak
-{
- import core.stdc.string;
- auto p = _d_newitemU(_ti);
- auto init = _ti.initializer();
- assert(init.length <= _ti.tsize);
- memcpy(p, init.ptr, init.length);
- return p;
-}
-
debug(PRINTF)
{
extern(C) void printArrayCache()
@@ -2361,52 +2334,6 @@ unittest
testPostBlit!(const(S))();
}
-// cannot define structs inside unit test block, or they become nested structs.
-version (CoreUnittest)
-{
- struct S1
- {
- int x = 5;
- }
- struct S2
- {
- int x;
- this(int x) {this.x = x;}
- }
- struct S3
- {
- int[4] x;
- this(int x)
- {this.x[] = x;}
- }
- struct S4
- {
- int *x;
- }
-
-}
-
-unittest
-{
- auto s1 = new S1;
- assert(s1.x == 5);
- assert(GC.getAttr(s1) == BlkAttr.NO_SCAN);
-
- auto s2 = new S2(3);
- assert(s2.x == 3);
- assert(GC.getAttr(s2) == BlkAttr.NO_SCAN);
-
- auto s3 = new S3(1);
- assert(s3.x == [1,1,1,1]);
- assert(GC.getAttr(s3) == BlkAttr.NO_SCAN);
- debug(SENTINEL) {} else
- assert(GC.sizeOf(s3) == 16);
-
- auto s4 = new S4;
- assert(s4.x == null);
- assert(GC.getAttr(s4) == 0);
-}
-
unittest
{
// Bugzilla 3454 - Inconsistent flag setting in GC.realloc()
@@ -2731,41 +2658,6 @@ unittest
assert(!test!InvalidMemoryOperationError);
}
-// test struct finalizers exception handling
-debug(SENTINEL) {} else
-unittest
-{
- bool test(E)()
- {
- import core.exception;
- static struct S1
- {
- E exc;
- ~this() { throw exc; }
- }
-
- bool caught = false;
- S1* s = new S1(new E("test onFinalizeError"));
- try
- {
- GC.runFinalizers((cast(char*)(typeid(S1).xdtor))[0..1]);
- }
- catch (FinalizeError err)
- {
- caught = true;
- }
- catch (E)
- {
- }
- GC.free(s);
- return caught;
- }
-
- assert( test!Exception);
- import core.exception : InvalidMemoryOperationError;
- assert(!test!InvalidMemoryOperationError);
-}
-
// test bug 14126
unittest
{