Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 7121ebc

Browse files
authored
Merge pull request #2127 from MartinNowak/merge_stable
Merge remote-tracking branch 'upstream/stable' into merge_stable merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2 parents 4d6650c + 290ea2a commit 7121ebc

File tree

6 files changed

+76
-56
lines changed

6 files changed

+76
-56
lines changed

changelog/core-memory-__delete.dd

Lines changed: 0 additions & 35 deletions
This file was deleted.

changelog/lazy-gc-init.dd

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/core/demangle.d

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ pure @safe:
208208
{
209209
assert( contains( dst[0 .. len], val ) );
210210
debug(info) printf( "removing (%.*s)\n", cast(int) val.length, val.ptr );
211-
212211
size_t v = &val[0] - &dst[0];
212+
assert( len >= val.length && len <= dst.length );
213+
len -= val.length;
213214
for (size_t p = v; p < len; p++)
214215
dst[p] = dst[p + val.length];
215-
len -= val.length;
216216
}
217217
}
218218

@@ -227,8 +227,7 @@ pure @safe:
227227
assert( !contains( dst[0 .. len], val ) );
228228
debug(info) printf( "appending (%.*s)\n", cast(int) val.length, val.ptr );
229229

230-
if( &dst[len] == &val[0] &&
231-
dst.length - len >= val.length )
230+
if( dst.length - len >= val.length && &dst[len] == &val[0] )
232231
{
233232
// data is already in place
234233
auto t = dst[len .. len + val.length];
@@ -2563,8 +2562,43 @@ version(unittest)
25632562
static assert( r == table[i][1],
25642563
"demangled \"" ~ table[i][0] ~ "\" as \"" ~ r ~ "\" but expected \"" ~ table[i][1] ~ "\"");
25652564
}
2565+
2566+
{
2567+
// https://issues.dlang.org/show_bug.cgi?id=18531
2568+
auto symbol = `_D3std3uni__T6toCaseS_DQvQt12toLowerIndexFNaNbNiNewZtVii1043S_DQCjQCi10toLowerTabFNaNbNiNemZwSQDo5ascii7toLowerTAyaZQDzFNaNeQmZ14__foreachbody2MFNaNeKmKwZ14__foreachbody3MFNaNeKwZi`;
2569+
auto demangled = `pure @trusted int std.uni.toCase!(std.uni.toLowerIndex(dchar), 1043, std.uni.toLowerTab(ulong), std.ascii.toLower, immutable(char)[]).toCase(immutable(char)[]).__foreachbody2(ref ulong, ref dchar).__foreachbody3(ref dchar)`;
2570+
auto dst = new char[200];
2571+
auto ret = demangle( symbol, dst);
2572+
assert( ret == demangled );
2573+
}
25662574
}
25672575

2576+
unittest
2577+
{
2578+
// https://issues.dlang.org/show_bug.cgi?id=18300
2579+
string s = demangle.mangleof;
2580+
foreach(i; 1..77)
2581+
{
2582+
char[] buf = new char[i];
2583+
auto ds = demangle(s, buf);
2584+
assert(ds == "pure nothrow @safe char[] core.demangle.demangle(const(char)[], char[])");
2585+
}
2586+
}
2587+
2588+
unittest
2589+
{
2590+
// https://issues.dlang.org/show_bug.cgi?id=18300
2591+
string s = "_D1";
2592+
string expected = "int ";
2593+
foreach (_; 0..10_000)
2594+
{
2595+
s ~= "a1";
2596+
expected ~= "a.";
2597+
}
2598+
s ~= "FiZi";
2599+
expected ~= "F";
2600+
assert(s.demangle == expected);
2601+
}
25682602

25692603
/*
25702604
*

src/core/internal/arrayop.d

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ T[] arrayOp(T : T[], Args...)(T[] res, Filter!(isType, Args) args) @trusted @nog
4040
// Given that there are at most as many scalars broadcast as there are
4141
// operations in any `ary[] = ary[] op const op const`, it should always be
4242
// worthwhile to choose vector operations.
43-
if (res.length >= vec.length)
43+
if (!__ctfe && res.length >= vec.length)
4444
{
4545
mixin(initScalarVecs!Args);
4646

@@ -574,3 +574,15 @@ unittest
574574
foreach (v; res[])
575575
assert(v == 2 * 3 + 4);
576576
}
577+
578+
unittest
579+
{
580+
// https://issues.dlang.org/show_bug.cgi?id=17964
581+
uint bug(){
582+
uint[] a = [1, 2, 3, 5, 6, 7];
583+
uint[] b = [1, 2, 3, 5, 6, 7];
584+
a[] |= ~b[];
585+
return a[1];
586+
}
587+
enum x = bug();
588+
}

src/core/stdc/stdlib.d

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,24 @@ extern (C):
3232
/* Placed outside @nogc in order to not constrain what the callback does.
3333
*/
3434
///
35-
alias int function(scope const void*, scope const void*) _compare_fp_t;
35+
alias int function(const void*, const void*) _compare_fp_t;
3636
///
37-
inout(void)* bsearch(scope const void* key, scope inout(void)* base, size_t nmemb, size_t size, _compare_fp_t compar);
37+
inout(void)* bsearch(const void* key, inout(void)* base, size_t nmemb, size_t size, _compare_fp_t compar);
3838
///
39-
void qsort(scope void* base, size_t nmemb, size_t size, _compare_fp_t compar);
39+
void qsort(void* base, size_t nmemb, size_t size, _compare_fp_t compar);
4040

41+
// https://issues.dlang.org/show_bug.cgi?id=17188
42+
@system unittest
43+
{
44+
struct S
45+
{
46+
extern(C) static int cmp(const void*, const void*) { return 0; }
47+
}
48+
int[4] arr;
49+
qsort(arr.ptr, arr[0].sizeof, arr.length, &S.cmp);
50+
int key;
51+
bsearch(&key, arr.ptr, arr[0].sizeof, arr.length, &S.cmp);
52+
}
4153

4254
nothrow:
4355
@nogc:

src/core/thread.d

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4286,18 +4286,18 @@ class Fiber
42864286
///////////////////////////////////////////////////////////////////////////
42874287

42884288

4289-
/**
4290-
* A fiber may occupy one of three states: HOLD, EXEC, and TERM. The HOLD
4291-
* state applies to any fiber that is suspended and ready to be called.
4292-
* The EXEC state will be set for any fiber that is currently executing.
4293-
* And the TERM state is set when a fiber terminates. Once a fiber
4294-
* terminates, it must be reset before it may be called again.
4295-
*/
4289+
/// A fiber may occupy one of three states: HOLD, EXEC, and TERM.
42964290
enum State
42974291
{
4298-
HOLD, ///
4299-
EXEC, ///
4300-
TERM ///
4292+
/** The HOLD state applies to any fiber that is suspended and ready to
4293+
be called. */
4294+
HOLD,
4295+
/** The EXEC state will be set for any fiber that is currently
4296+
executing. */
4297+
EXEC,
4298+
/** The TERM state is set when a fiber terminates. Once a fiber
4299+
terminates, it must be reset before it may be called again. */
4300+
TERM
43014301
}
43024302

43034303

0 commit comments

Comments
 (0)