From cce577165b73c66401b0f912fbe0811499d29d29 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 29 Jun 2018 19:23:37 +0200 Subject: [PATCH 1/4] Fix std.experimental.allocator.common.effectiveAlignment() It was unable to handle alignments > 2^31 bytes, e.g., returning 2 for the 64-bit pointer 0x2FA_00000000. Return a size_t instead of a uint. Note that it's only called in one place, an assertion in a ctor of the BitmappedBlockImpl mixin, which handles size_t fine. This fixes sporadic std.experimental.allocator.building_blocks.bitmapped_block unittest failures for LDC CI on Win64 (something like 1 out of 100 runs failing). --- .../allocator/building_blocks/bitmapped_block.d | 2 +- std/experimental/allocator/common.d | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/std/experimental/allocator/building_blocks/bitmapped_block.d b/std/experimental/allocator/building_blocks/bitmapped_block.d index 04cb468a843..33da3480488 100644 --- a/std/experimental/allocator/building_blocks/bitmapped_block.d +++ b/std/experimental/allocator/building_blocks/bitmapped_block.d @@ -99,7 +99,7 @@ private mixin template BitmappedBlockImpl(bool isShared, bool multiBlock) auto leadingUlongs = blocks.divideRoundUp(64); import std.algorithm.comparison : min; immutable initialAlignment = min(parentAlignment, - 1U << trailingZeros(leadingUlongs * 8)); + 1U << min(31U, trailingZeros(leadingUlongs * 8))); auto maxSlack = alignment <= initialAlignment ? 0 : alignment - initialAlignment; diff --git a/std/experimental/allocator/common.d b/std/experimental/allocator/common.d index 199ce1cb724..202eb5cd00d 100644 --- a/std/experimental/allocator/common.d +++ b/std/experimental/allocator/common.d @@ -287,9 +287,9 @@ Returns the effective alignment of `ptr`, i.e. the largest power of two that is a divisor of `ptr`. */ @nogc nothrow pure -package uint effectiveAlignment(void* ptr) +package size_t effectiveAlignment(void* ptr) { - return 1U << trailingZeros(cast(size_t) ptr); + return (cast(size_t) 1) << trailingZeros(cast(size_t) ptr); } @nogc nothrow pure @@ -297,6 +297,9 @@ package uint effectiveAlignment(void* ptr) { int x; assert(effectiveAlignment(&x) >= int.alignof); + + const max = (cast(size_t) 1) << (size_t.sizeof * 8 - 1); + assert(effectiveAlignment(cast(void*) max) == max); } /* From f28ffcc727c55b66084b9d28f5e11f015518f59f Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Wed, 27 Jun 2018 05:53:06 +0200 Subject: [PATCH 2/4] Bump Dscanner to 6d526bbf25ce662587c10d7e52bae800585f6846 --- posix.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posix.mak b/posix.mak index cef244ff2ff..d950d92ca77 100644 --- a/posix.mak +++ b/posix.mak @@ -82,7 +82,7 @@ ROOT_OF_THEM_ALL = generated ROOT = $(ROOT_OF_THEM_ALL)/$(OS)/$(BUILD)/$(MODEL) DUB=dub TOOLS_DIR=../tools -DSCANNER_HASH=39496ede1a2c00674c4e04b6513be7cc9aee6cef +DSCANNER_HASH=6d526bbf25ce662587c10d7e52bae800585f6846 DSCANNER_DIR=$(ROOT_OF_THEM_ALL)/dscanner-$(DSCANNER_HASH) # Set DRUNTIME name and full path From c246113423a6e770602c6a52f7ebda84b36b3f3d Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 28 Jun 2018 10:58:14 +0200 Subject: [PATCH 3/4] Fix auto function without return statement --- std/experimental/typecons.d | 6 +++--- std/traits.d | 12 ++++++------ std/typecons.d | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/std/experimental/typecons.d b/std/experimental/typecons.d index 9c1d0f21fdf..d642557ad2b 100644 --- a/std/experimental/typecons.d +++ b/std/experimental/typecons.d @@ -58,14 +58,14 @@ if (is(T == class) || is(T == interface)) @system unittest { - class C { @disable opCast(T)() {} } + class C { @disable void opCast(T)(); } auto c = new C; static assert(!__traits(compiles, cast(Object) c)); auto o = dynamicCast!Object(c); assert(c is o); - interface I { @disable opCast(T)() {} Object instance(); } - interface J { @disable opCast(T)() {} Object instance(); } + interface I { @disable void opCast(T)(); Object instance(); } + interface J { @disable void opCast(T)(); Object instance(); } class D : I, J { Object instance() { return this; } } I i = new D(); static assert(!__traits(compiles, cast(J) i)); diff --git a/std/traits.d b/std/traits.d index 1fffb9746f0..3a7e6effe88 100644 --- a/std/traits.d +++ b/std/traits.d @@ -2001,9 +2001,9 @@ if (isCallable!func) static assert(!isSafe!(Set.systemF)); //Functions - @safe static safeFunc() {} - @trusted static trustedFunc() {} - @system static systemFunc() {} + @safe static void safeFunc() {} + @trusted static void trustedFunc() {} + @system static void systemFunc() {} static assert( isSafe!safeFunc); static assert( isSafe!trustedFunc); @@ -2077,9 +2077,9 @@ template isUnsafe(alias func) static assert( isUnsafe!(Set.systemF)); //Functions - @safe static safeFunc() {} - @trusted static trustedFunc() {} - @system static systemFunc() {} + @safe static void safeFunc() {} + @trusted static void trustedFunc() {} + @system static void systemFunc() {} static assert(!isUnsafe!safeFunc); static assert(!isUnsafe!trustedFunc); diff --git a/std/typecons.d b/std/typecons.d index 29fe2978577..203ab05f43f 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -5151,14 +5151,14 @@ if (is(T == class) || is(T == interface)) @system unittest { - class C { @disable opCast(T)() {} } + class C { @disable void opCast(T)(); } auto c = new C; static assert(!__traits(compiles, cast(Object) c)); auto o = dynamicCast!Object(c); assert(c is o); - interface I { @disable opCast(T)() {} Object instance(); } - interface J { @disable opCast(T)() {} Object instance(); } + interface I { @disable void opCast(T)(); Object instance(); } + interface J { @disable void opCast(T)(); Object instance(); } class D : I, J { Object instance() { return this; } } I i = new D(); static assert(!__traits(compiles, cast(J) i)); From 4197828932675872af88e86964e5ffbbd596b4aa Mon Sep 17 00:00:00 2001 From: Martin Nowak Date: Wed, 4 Jul 2018 00:15:07 +0200 Subject: [PATCH 4/4] purge changelog --- changelog/remove_std_c.dd | 3 --- changelog/std-algorithm-iteration-joiner.dd | 19 --------------- changelog/std-algorithm-mutation-remove.dd | 27 --------------------- changelog/std-math-fminmax.dd | 19 --------------- 4 files changed, 68 deletions(-) delete mode 100644 changelog/remove_std_c.dd delete mode 100644 changelog/std-algorithm-iteration-joiner.dd delete mode 100644 changelog/std-algorithm-mutation-remove.dd delete mode 100644 changelog/std-math-fminmax.dd diff --git a/changelog/remove_std_c.dd b/changelog/remove_std_c.dd deleted file mode 100644 index 37b83def468..00000000000 --- a/changelog/remove_std_c.dd +++ /dev/null @@ -1,3 +0,0 @@ -The deprecated `std.c` package has been removed. - -Use the `core.stdc` package instead. diff --git a/changelog/std-algorithm-iteration-joiner.dd b/changelog/std-algorithm-iteration-joiner.dd deleted file mode 100644 index 0ae4b279662..00000000000 --- a/changelog/std-algorithm-iteration-joiner.dd +++ /dev/null @@ -1,19 +0,0 @@ -The performance of `std.algorithm.iteration.joiner` has been improved - -$(H4 DMD) - -$(CONSOLE -> dmd -O -inline -release ./joiner.d && ./joiner -before.joiner = 57 secs, 834 ms, 289 μs, and 3 hnsecs -new.joiner = 44 secs, 936 ms, 706 μs, and 5 hnsecs -) - -$(H4 LDC) - -$(CONSOLE -> ldmd -O3 -release -inline joiner.d && ./joiner -before.joiner = 5 secs, 180 ms, 193 μs, and 7 hnsecs -new.joiner = 3 secs, 168 ms, 560 μs, and 6 hnsecs -) - -The benchmark code can be found $(LINK2 https://gist.github.com/wilzbach/ffd5d20639766a831fd4b1962572897a, here). diff --git a/changelog/std-algorithm-mutation-remove.dd b/changelog/std-algorithm-mutation-remove.dd deleted file mode 100644 index e1c02f3a77e..00000000000 --- a/changelog/std-algorithm-mutation-remove.dd +++ /dev/null @@ -1,27 +0,0 @@ -`std.algorithm.mutation.remove` now only accepts integral values or pair of integral values as offset - -Previously, without being stated in the documentation, -$(REF remove, std,algorithm) used to accept any values as `offset`. -This behavior was very error-prone: - ---- -import std.algorithm, std.stdio; -[0, 1, 2, 3, 4].remove(1, 3).writeln; // 0, 2, 4 -- correct -[0, 1, 2, 3, 4].remove([1, 3]).writeln; // 0, 3, 4 -- incorrect ---- - -With this release, using arrays as individual elements is no longer valid. -$(REF tuple, std,typecons) can be used to explicitly indicate that a range -from `start` to `stop` (non-enclosing) should be removed: - ---- -import std.algorithm, std.stdio, std.typecons; -[0, 1, 2, 3, 4].remove(tuple(1, 3)).writeln; // 0, 3, 4 ---- - -However, only 2-tuples are allowed to avoid this un-intuitive scenario: - ---- -import std.algorithm, std.stdio, std.typecons; -[0, 1, 2, 3, 4].remove(tuple(1, 3, 4)).writeln; // 0, 4? ---- diff --git a/changelog/std-math-fminmax.dd b/changelog/std-math-fminmax.dd deleted file mode 100644 index ff8afb3f55a..00000000000 --- a/changelog/std-math-fminmax.dd +++ /dev/null @@ -1,19 +0,0 @@ -Changed semantics of std.math.{fmin,fmax} wrt. NaNs. - -The semantics of $(REF fmin, std, math) and $(REF fmax, std, math) have been -streamlined with the C functions: if one of the arguments is a NaN, return the -other. This involves an additional $(REF isNaN, std, math) check. Use -$(REF min, std, algorithm, comparison) and $(REF max, std, algorithm, comparison) -for the previous semantics performing a single comparison. - ---- -import std.math; -assert(fmin(real.nan, 2.0L) == 2.0L); -assert(fmin(2.0L, real.nan) == 2.0L); // previously: NaN -assert(isNaN(fmin(real.nan, real.nan))); - -import std.algorithm.comparison; -assert(min(real.nan, 2.0L) == 2.0L); -assert(isNaN(min(2.0L, real.nan))); -assert(isNaN(min(real.nan, real.nan))); ----