[Issue 18923] Semaphore internal handle should be `protected` instead of `private`

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18923

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 18923] Semaphore internal handle should be `protected` instead of `private`

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18923

--- Comment #1 from github-bugzi...@puremagic.com ---
Commit pushed to master at https://github.com/dlang/druntime

https://github.com/dlang/druntime/commit/e43b889a331323790ce151533223ac6ec8166a79
fix issue 18923 - Semaphore internal handle should be `protected`

--


[Issue 18996] New: Inserting a struct into an std.container Array causes SIGILL(4). Illegal Instruction.

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18996

  Issue ID: 18996
   Summary: Inserting a struct into an std.container Array causes
SIGILL(4). Illegal Instruction.
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: regression
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: viserion.thr...@gmail.com

The following code causes a SIGILL or signal 4 on Linux.

import std.container;

struct Record
{
string name;
}

struct Foo(T)
{
alias RecordArray = Array!T;

void test()
{
T value;
array_.insert(value);
}

RecordArray array_;
}

void main(string[] arguments)
{
Foo!Record foo;
foo.test();
}

I don't have much experience with gdb so this is the best I could do:

(gdb) run
Starting program: /home/soulsbane/Projects/D/ssloc/ssloc 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
0x55614204 in _D2gc4impl5protoQo7ProtoGC11removeRangeMFNbNiPvZv ()
(gdb) bt
#0  0x55614204 in _D2gc4impl5protoQo7ProtoGC11removeRangeMFNbNiPvZv ()
#1  0x555f52c3 in gc_removeRange ()
#2  0x555f4a05 in core.memory.GC.removeRange(const(void*)) ()
#3  0x555e119e in
_D3std9container5array__T5ArrayTS3app6RecordZQu7Payload7reserveMFNbNimZv
(this=..., elements=1) at /usr/include/dlang/dmd/std/container/array.d:382
#4  0x555e43f0 in
_D3std9container5array__T5ArrayTS3app6RecordZQu7Payload__T10insertBackTQBnZQrMFNbNiQBzZm
(this=..., elem=...) at /usr/include/dlang/dmd/std/container/array.d:404
#5  0x555e433a in
_D3std9container5array__T5ArrayTS3app6RecordZQu__T10insertBackTQBfZQrMFNbNiQBrZm
(this=..., stuff=...) at /usr/include/dlang/dmd/std/container/array.d:831
#6  0x555e0d2a in _D3app__T3FooTSQn6RecordZQq4testMFNbNiZv (this=...)
at source/app.d:73
#7  0x555e0c31 in D main (arguments=...) at source/app.d:82
(gdb) disas
Dump of assembler code for function
_D2gc4impl5protoQo7ProtoGC11removeRangeMFNbNiPvZv:
   0x55614044 <+0>: push   %rbp
   0x55614045 <+1>: mov%rsp,%rbp
   0x55614048 <+4>: sub$0x40,%rsp
   0x5561404c <+8>: mov%rbx,-0x40(%rbp)
   0x55614050 <+12>:mov%r12,-0x38(%rbp)
   0x55614054 <+16>:mov%r13,-0x30(%rbp)
   0x55614058 <+20>:mov%r14,-0x28(%rbp)
   0x5561405c <+24>:mov%rdi,-0x8(%rbp)
   0x55614060 <+28>:mov%rsi,%rdx
   0x55614063 <+31>:mov%rdi,%rcx
   0x55614066 <+34>:add$0x28,%rcx
   0x5561406a <+38>:mov0x8(%rcx),%r8
   0x5561406e <+42>:mov(%rcx),%r9
   0x55614071 <+45>:test   %r8,%r8
   0x55614074 <+48>:je 0x55614204
<_D2gc4impl5protoQo7ProtoGC11removeRangeMFNbNiPvZv+448>
   0x5561407a <+54>:mov%r9,%rcx
   0x5561407d <+57>:cmp%rdx,(%rcx)
   0x55614080 <+60>:jne0x556141e4
<_D2gc4impl5protoQo7ProtoGC11removeRangeMFNbNiPvZv+416>
   0x55614086 <+66>:mov-0x8(%rbp),%r8
   0x5561408a <+70>:add$0x28,%r8
   0x5561408e <+74>:mov%r8,-0x20(%rbp)
   0x55614092 <+78>:mov0x8(%r8),%rsi
   0x55614096 <+82>:mov(%r8),%rdx
   0x55614099 <+85>:lea(%rsi,%rsi,2),%rsi
   0x5561409d <+89>:lea-0x18(%rdx,%rsi,8),%rsi
   0x556140a5 <+97>:mov%rcx,%rdi
   0x556140a8 <+100>:   movsq  %ds:(%rsi),%es:(%rdi)
   0x556140aa <+102>:   movsq  %ds:(%rsi),%es:(%rdi)
   0x556140ac <+104>:   movsq  %ds:(%rsi),%es:(%rdi)
   0x556140ae <+106>:   xor%eax,%eax
   0x556140b0 <+108>:   mov%al,-0x10(%rbp)
   0x556140b3 <+111>:   mov-0x20(%rbp),%r14
   0x556140b7 <+115>:   mov0x8(%r14),%r13
   0x556140bb <+119>:   dec%r13
   0x556140be <+122>:   mov%r13,%r9
   0x556140c1 <+125>:   lea(%r9,%r9,2),%rbx
   0x556140c5 <+129>:   lea0x0(,%rbx,8),%rbx
   0x556140cd <+137>:   mov%r13,%rdx
   0x556140d0 <+140>:   or $0x18,%rdx
   0x556140d7 <+147>:   shr$0x20,%rdx
   0x556140db <+151>:   je 0x556140fa
<_D2gc4impl5protoQo7ProtoGC11removeRangeMFNbNiPvZv+182>
   0x556140dd <+153>:   mov%rbx,%rax
   0x556140e0 <+156>:   movabs $0xaaab,%rdx
   0x556140ea <+166>:   mul%rdx
   0x556140ed <+169>:   shr$0x4,%rdx
   0x556140f1 <+173>:   cmp%r13,%rdx
   0x556140f4 <+176>:   je 0x556140fa
<_D2gc4impl5protoQo7ProtoGC11removeRangeMFNbNiPvZv+182>
   0x556140f6 <+178>:   movb  

[Issue 18026] Stack overflow in ddmd/dtemplate.d:6241, TemplateInstance::needsCodegen()

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18026

Stefan Koch  changed:

   What|Removed |Added

 CC||uplink.co...@gmail.com

--- Comment #12 from Stefan Koch  ---
This is caused by a giant chain of templates.

I will take a look.

--


[Issue 17712] [REG 2.074] [LINK] Undefined reference to std.conv.toChars!(10, char, 1, uint).toChars(uint)

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17712

Mike Franklin  changed:

   What|Removed |Added

 CC||slavo5...@yahoo.com

--- Comment #14 from Mike Franklin  ---
This bug would be much easier to troubleshoot if it could be reduced to a
couple of modules and *not* import any Phobos module.  A -betterC reproduction
would be even better.  There's just too much noise when parsing and
semantic-processing Phobos modules to see what's wrong and where.

--


[Issue 18966] extern(C++) constructor should match C++ semantics assigning vtable

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18966

Rainer Schuetze  changed:

   What|Removed |Added

   Keywords||pull
 CC||r.sagita...@gmx.de

--- Comment #1 from Rainer Schuetze  ---
https://github.com/dlang/dmd/pull/8362

--


[Issue 18998] Improve Operator Overloading docs

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18998

--- Comment #1 from Manu  ---
I also suggest, for each operator as it is introduced, demonstrate the
'canonical' signature; what is the 'most standard/correct' way to specify these
functions in their most simple cases.

Imagine you were writing a D equivalent of std::vector, nothing could be
simpler in terms of API spec.
Read the section "Array Indexing and Slicing Operators Overloading" from the
perspective you were writing std::vector...

What indexing type to use? size_t?
What about argument ref-ness? ref? byval? auto ref?
Argument const-ness?
What should assignment operators return? `void`? A reference to `this` like
C++?
How to correctly handle the operators that receive strings?
  constraint: int opBinary(string op) if (op == "+") { ... }
  specialisation: int opBinary(string op : "+") { ... }
  static-if:  int opBinary(string op) { static if (op == "+") { ... } }
Each have subtly different semantics with respect to overload selection, error
messages, etc. Default choices should be suggested.

This information being clearly provided will ensure that development of D
container classes will follow the same set of guidelines.

It's worth noting, the document is almost obsessed with 2-d
slicing/indexing/op-assignment concepts.
Make a point that multi-dimensional indexing is even supported, and that it is
a separate topic, and requires different handling than 1d.
Users might not imagine that multi-dimensional indexing/slicing is possible on
first contact.

I suggest establishing all indexing/slicing operators with respect to their
typical 1-d cases, and then have a specific section at the end relating n-d (or
2-d in this case) indexing/slicing mechanics.

--


[Issue 18958] extern(C++) wchar, dchar mangling not correct

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18958

--- Comment #2 from Manu  ---
Separate issue creates for wchar_t:
https://issues.dlang.org/show_bug.cgi?id=18997

PR for this issue here: https://github.com/dlang/dmd/pull/8342

Problem is unit-tests that link against DMC++ fail, because DMC doesn't support
utf16/32 char types.

--


[Issue 18999] New: MSCRT selection specifies _ITERATOR_DEBUG_LEVEL and produces a `version`

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18999

  Issue ID: 18999
   Summary: MSCRT selection specifies _ITERATOR_DEBUG_LEVEL and
produces a `version`
   Product: D
   Version: D2
  Hardware: All
OS: Windows
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: turkey...@gmail.com

For Win32/Win64, `_ITERATOR_DEBUG_LEVEL` needs to be embedded in the binary
with the value 0 or 2 matching the version of mscrt that was selected.
0 for release runtime, 2 for debug runtime.
If no crt is selected, then it should be omitted.

This will allow D objects to link against C++ objects that were built for the
respective runtime.

We also need a version() for the mscrt selected at compile time, so that we can
guide struct contents against the runtime selected (STL structs have different
content based on _ITERATOR_DEBUG_LEVEL)


A resolution to this problem might be if only a version were specified, and
also a pragma that allowed embedding _ITERATOR_DEBUG_LEVEL only when a module
imports a `core.stdcpp` module. That way only objects that interact with STL
would entail the linkage problems associated with microsoft's runtime.

--


[Issue 18997] New: extern(C++) mangling incorrect for wchar_t

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18997

  Issue ID: 18997
   Summary: extern(C++) mangling incorrect for wchar_t
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: major
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: turkey...@gmail.com

DMD treats wchar_t like an alias, which leads to incorrect mangling.
MSVC mangles as '_W', and posix as 'w'.

--


[Issue 18997] extern(C++) mangling incorrect for wchar_t

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18997

Manu  changed:

   What|Removed |Added

   Keywords||C++

--


[Issue 18998] Improve Operator Overloading docs

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18998

--- Comment #2 from Manu  ---
Convenience link: https://dlang.org/spec/operatoroverloading.html

--


[Issue 18558] Template alias spec incomplete

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18558

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 18558] Template alias spec incomplete

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18558

--- Comment #5 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dlang.org

https://github.com/dlang/dlang.org/commit/9c53bdc77ba51f30ca3170aa02484ddd0e9ce3ef
Fix Issue 18558 - Template alias spec incomplete

https://github.com/dlang/dlang.org/commit/d2e6f38fe8300cf23ae52c943d9a33a4f9a1448c
Merge pull request #2382 from ntrel/alias-val

Fix Issue 18558 - Template alias spec incomplete

--


[Issue 19000] New: Building botan library causes segfault in dsymbolsem.d

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=19000

  Issue ID: 19000
   Summary: Building botan library causes segfault in dsymbolsem.d
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: regression
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: triple...@protonmail.com

Building botan with dmd (or associated ldc) versions greater than 2.078.3 (or
slightly earlier) can cause a segfault in dsymbolsem.d. 

The class is :
private extern(C++) final class DsymbolSemanticVisitor : Visitor

The function is:
override void visit(CtorDeclaration ctd)
{
//printf("CtorDeclaration::semantic() %s\n", toChars());
if (ctd.semanticRun >= PASS.semanticdone)
return;
if (ctd._scope)
{
sc = ctd._scope;
ctd._scope = null;
}

ctd.parent = sc.parent;
Dsymbol p = ctd.toParent2();
AggregateDeclaration ad = p.isAggregateDeclaration();
if (!ad)
{
error(ctd.loc, "constructor can only be a member of aggregate, not
%s `%s`", p.kind(), p.toChars());
ctd.type = Type.terror;
ctd.errors = true;
return;
}

sc = sc.push();

if (sc.stc & STC.static_)
{
// Deprecated in 2018-04.
// Change to error in 2019-04.
// @@@DEPRECATED_2019-04@@@.
if (sc.stc & STC.shared_)
deprecation(ctd.loc, "`shared static` has no effect on a
constructor inside a `shared static` block. Use `shared static this()`");
else
deprecation(ctd.loc, "`static` has no effect on a constructor
inside a `static` block. Use `static this()`");
}

sc.stc &= ~STC.static_; // not a static constructor
sc.flags |= SCOPE.ctor;

funcDeclarationSemantic(ctd);

sc.pop();

if (ctd.errors)
return;

TypeFunction tf = ctd.type.toTypeFunction();

/* See if it's the default constructor
 * But, template constructor should not become a default constructor.
 */
if (ad && (!ctd.parent.isTemplateInstance() ||
ctd.parent.isTemplateMixin()))
{
immutable dim = Parameter.dim(tf.parameters);

if (auto sd = ad.isStructDeclaration())
{
if (dim == 0 && tf.varargs == 0) // empty default ctor w/o any
varargs
{
if (ctd.fbody || !(ctd.storage_class & STC.disable))
{
ctd.error("default constructor for structs only allowed
" ~
"with `@disable`, no body, and no parameters");
ctd.storage_class |= STC.disable;
ctd.fbody = null;
}
sd.noDefaultCtor = true;
}
else if (dim == 0 && tf.varargs) // allow varargs only ctor
{
}
else if (dim && Parameter.getNth(tf.parameters, 0).defaultArg)
{
// if the first parameter has a default argument, then the
rest does as well
if (ctd.storage_class & STC.disable)
{
ctd.deprecation("is marked `@disable`, so it cannot
have default "~
"arguments for all parameters.");
deprecationSupplemental(ctd.loc, "Use `@disable
this();` if you want to disable default initialization.");
}
else
ctd.deprecation("all parameters have default arguments,
"~
"but structs cannot have default
constructors.");
}
}
else if (dim == 0 && tf.varargs == 0)
{
ad.defaultCtor = ctd;
}
}
}

Specifically, the line where it segfaults is:
ctd.parent = sc.parent;

--


[Issue 18934] std.concurrency receive throws assertion failure if message is a struct containing const data

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18934

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 18934] std.concurrency receive throws assertion failure if message is a struct containing const data

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18934

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/2de6f8da22615e97e016a0e7aecb39f6d5e322d0
Fix issue 18934 - make std.variant support getting types that have const
members.

https://github.com/dlang/phobos/commit/cc961daf3220df387a1ae48b8e7c938ce6dee8da
Merge pull request #6544 from schveiguy/fix18934

Fix issue 18934 - make std.variant support getting types that have const
members

--


[Issue 18958] extern(C++) wchar, dchar mangling not correct

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18958

--- Comment #3 from Manu  ---
Actually, it looks like DMC++ *does* support char16_t/char32_t:
https://www.digitalmars.com/ctg/CPP0x-Language-Implementation.html

Just need to jig the unit-tests to make sure that's invoked somehow?

--


[Issue 18998] New: Improve Operator Overloading docs

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18998

  Issue ID: 18998
   Summary: Improve Operator Overloading docs
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: turkey...@gmail.com

The language Operator Overloading document has devolved into chaos!

Picture that you don't know D, and you want to learn about operator
overloading, and now read that document.

Press Ctrl-F and type "opSlice", scroll the highlighted text, try and
understand how to implement a slicing operator properly. Note that the first
contact you see looks like this:
  `-a[i..j]a.opIndexUnary!("-")(a.opSlice(i, j))`  wat?!

I think this document needs a complete overhaul, starting with a list of
special operators that exist, description of each special operator and example
of how they work in **the most simple case**, and show complex compounds and
aggregate rewrites towards the end, only after the basic meaning of all
operators has been established.

This is a critical language document, and it's not terribly helpful to new
users.

--


[Issue 18026] Stack overflow in ddmd/dtemplate.d:6241, TemplateInstance::needsCodegen()

2018-06-16 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18026

--- Comment #13 from JR  ---
(In reply to Stefan Koch from comment #12)
> This is caused by a giant chain of templates.
> 
> I will take a look.

Thank you!

If you need more dustmite examples I can generate those on demand.

--