From c9f7090d930504db772557c18f16599e03d616ea Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Tue, 7 Jan 2025 20:49:06 +0100 Subject: d: Merge upstream dmd, druntime 82a5d2a7c4, phobos dbc09d823 D front-end changes: - Import latest fixes from dmd v2.110.0-beta.1. - Added traits `getBitfieldOffset' and `getBitfieldWidth'. - Added trait `isCOMClass' to detect if a type is a COM class. - Added `-fpreview=safer` which enables safety checking on unattributed functions. D runtime changes: - Import latest fixes from druntime v2.110.0-beta.1. Phobos changes: - Import latest fixes from phobos v2.110.0-beta.1. - Added `fromHexString' and `fromHexStringAsRange' functions to `std.digest'. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 82a5d2a7c4. * d-lang.cc (d_handle_option): Handle new option `-fpreview=safer'. * expr.cc (ExprVisitor::NewExp): Remove gcc_unreachable for the generation of `_d_newThrowable'. * lang.opt: Add -fpreview=safer. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 82a5d2a7c4. * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/internal/gc/blkcache.d, core/internal/gc/blockmeta.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos dbc09d823. --- libphobos/src/std/algorithm/searching.d | 82 +++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'libphobos/src/std/algorithm') diff --git a/libphobos/src/std/algorithm/searching.d b/libphobos/src/std/algorithm/searching.d index 42a9df5..b7119d2 100644 --- a/libphobos/src/std/algorithm/searching.d +++ b/libphobos/src/std/algorithm/searching.d @@ -3735,6 +3735,47 @@ if (isInputRange!Range && !isInfinite!Range && assert(arr.minElement!"a.val".val == 0); } +// https://issues.dlang.org/show_bug.cgi?id=24827 +@safe unittest +{ + static struct S + { + int i; + bool destroyed; + + this(int i) @safe + { + this.i = i; + } + + ~this() @safe + { + destroyed = true; + } + + bool opEquals()(auto ref S rhs) + { + return this.i == rhs.i; + } + + int opCmp()(auto ref S rhs) + { + if (this.i < rhs.i) + return -1; + + return this.i == rhs.i ? 0 : 1; + } + + @safe invariant + { + assert(!destroyed); + } + } + + auto arr = [S(19), S(2), S(145), S(7)]; + assert(minElement(arr) == S(2)); +} + /** Iterates the passed range and returns the maximal element. A custom mapping function can be passed to `map`. @@ -3888,6 +3929,47 @@ if (isInputRange!Range && !isInfinite!Range && assert(arr[0].getI == 2); } +// https://issues.dlang.org/show_bug.cgi?id=24827 +@safe unittest +{ + static struct S + { + int i; + bool destroyed; + + this(int i) @safe + { + this.i = i; + } + + ~this() @safe + { + destroyed = true; + } + + bool opEquals()(auto ref S rhs) + { + return this.i == rhs.i; + } + + int opCmp()(auto ref S rhs) + { + if (this.i < rhs.i) + return -1; + + return this.i == rhs.i ? 0 : 1; + } + + @safe invariant + { + assert(!destroyed); + } + } + + auto arr = [S(19), S(2), S(145), S(7)]; + assert(maxElement(arr) == S(145)); +} + // minPos /** Computes a subrange of `range` starting at the first occurrence of `range`'s -- cgit v1.1