[Issue 17220] invalid code with -m32 -inline and struct that's 4x the size of an assigned enum value

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17220

Stefan Koch  changed:

   What|Removed |Added

   Hardware|x86 |x86_64

--- Comment #1 from Stefan Koch  ---
Happens on 64bit as well
Slightly modified:

void emitArithInstruction2(BCValue lhs)
{
if (lhs.type != BCTypeEnum.i32) // type get's overwritten
assert(0);
}

enum BCTypeEnum : ubyte
{
Undef,
i32 = 8, // value must be >= 8
}

struct BCValue // size must be size_t.sizeof x BCTypeEnum.i32
{
BCTypeEnum type; // position doesn't matter
ubyte[size_t.sizeof * BCTypeEnum.i32 - type.sizeof] more;
}
static assert(BCValue.sizeof == size_t.sizeof * BCTypeEnum.i32);

BCValue i32()
{
BCValue result; // must be default 0 initialized
result.type = BCTypeEnum.i32; // set value
return result;
}

void main()
{
auto val = i32();
emitArithInstruction2(val);
}
CODE

--


[Issue 17220] invalid code with -m32 -inline and struct that's 4x the size of an assigned enum value

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17220

Stefan Koch  changed:

   What|Removed |Added

 CC||uplink.co...@gmail.com
 OS|Linux   |All
   Severity|normal  |major

--


[Issue 17220] New: invalid code with -m32 -inline and struct that's 4x the size of an assigned enum value

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17220

  Issue ID: 17220
   Summary: invalid code with -m32 -inline and struct that's 4x
the size of an assigned enum value
   Product: D
   Version: D2
  Hardware: x86
OS: Linux
Status: NEW
  Keywords: wrong-code
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: c...@dawg.eu

cat > bug.d << CODE
void emitArithInstruction2(BCValue lhs)
{
if (lhs.type != BCTypeEnum.i32) // type get's overwritten
assert(0);
}

enum BCTypeEnum : ubyte
{
Undef,
i32 = 8, // value must be >= 8
}

struct BCValue // size must be 4 x BCTypeEnum.i32
{
BCTypeEnum type; // position doesn't matter
ubyte[4 * BCTypeEnum.i32 - type.sizeof] more;
}
static assert(BCValue.sizeof == 4 * BCTypeEnum.i32);

BCValue i32()
{
BCValue result; // must be default 0 initialized
result.type = BCTypeEnum.i32; // set value
return result;
}

void main()
{
auto val = i32();
emitArithInstruction2(val);
}
CODE
dmd -m32 -inline -run bug

mov cl, 8   ; 0806B698 _ B1, 08
mov byte ptr [ebp-40H], cl  ; 0806B69A _ 88. 4D, C0
lea esi, [ebp-40H]  ; 0806B69D _ 8D. 75, C0
lea edi, [ebp-20H]  ; 0806B6A0 _ 8D. 7D, E0
cmp byte ptr [ebp-20H], 8   ; 0806B6A3 _ 80. 7D,
E0, 08
jz  ?_0170  ; 0806B6A7 _ 74, 07
mov al, 4   ; 0806B6A9 _ B0, 04
call_D3bug8__assertFiZv ; 0806B6AB _ E8,
0028


The cmp instruction uses a wrong memory location for the struct.


Same with i32 = 10 and BCValue.sizeof == 40, so it's not dependent on 32 size
of the struct, but below 32-byte struct initialization is done differently (and
the bug vanishes).

mov cl, 10  ; 0806B698 _ B1, 0A
mov byte ptr [ebp-58H], cl  ; 0806B69A _ 88. 4D, A8
lea esi, [ebp-58H]  ; 0806B69D _ 8D. 75, A8
lea edi, [ebp-28H]  ; 0806B6A0 _ 8D. 7D, D8
cmp byte ptr [ebp-28H], 10  ; 0806B6A3 _ 80. 7D,
D8, 0A
jz  ?_0170  ; 0806B6A7 _ 74, 07



This reduced test-case is not reproducible with -O, but the original bug
instance is.

--


[Issue 17218] foreach on tupleof inside switch returns ref to undefined address

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17218

ZombineDev  changed:

   What|Removed |Added

   Keywords||wrong-code
 CC||petar.p.ki...@gmail.com
   Hardware|x86_64  |All
   Severity|minor   |major

--


[Issue 14413] Spurious newline in ddoc JSON output for multiple successive line doc comments

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14413

Nick Sabalausky  changed:

   What|Removed |Added

 Resolution|WONTFIX |FIXED

--- Comment #10 from Nick Sabalausky  ---
The PR for this was merged
(https://github.com/D-Programming-Language/dmd/pull/4745), so probably
shouldn't be marked "WONTFIX" anymore.

--


[Issue 11847] Importing "package.d" module causes qualified name lookup to fail for sub modules

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11847

ZombineDev  changed:

   What|Removed |Added

 CC||petar.p.ki...@gmail.com

--


[Issue 17219] variable shadowing and overload sets

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17219

--- Comment #1 from John Colvin  ---
One also gets this weirdness:

void foo(alias bar)()
{
static int bar0(T...)(T t) { return 0; }
alias bar = bar0;
pragma(msg, __traits(identifier, __traits(parent, bar!int)));
pragma(msg, __traits(identifier, __traits(parent, __traits(parent,
bar!int;
}

int blah(T)(T t) { return 1; }

void main()
{
foo!blah;
}

output:
bar0
bar0

I.e. __traits(parent, ...) ends up idempotent.

--


[Issue 17219] New: variable shadowing and overload sets

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17219

  Issue ID: 17219
   Summary: variable shadowing and overload sets
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: john.loughran.col...@gmail.com

void foo(alias bar)()
{
static int bar0(T...)(T t) { return 0; }
alias bar = bar0;
import std.stdio;
writeln(bar(3));
}

int blah(T)(T t) { return 1; }

void main()
{
foo!blah;
}

currently this successfully compiles and prints 0. I think it should either
fail to compile ("bar already defined") or print 1 as blah and bar0 form an
overload set.

--


[Issue 17164] [REG 2.072.0] undefined identifier '__va_argsave'

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17164

--- Comment #2 from Jacob Carlborg  ---
It's documented for D1 [1], under "C-style Variadic Functions". I still think
it's a regressions, this code originated from D1.

[1] http://www.digitalmars.com/d/1.0/function.html

--


[Issue 17218] foreach on tupleof inside switch returns ref to undefined address

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17218

Alex Goltman  changed:

   What|Removed |Added

   Hardware|x86 |x86_64
 OS|Mac OS X|All

--


[Issue 17218] New: foreach on tupleof inside switch returns ref to undefined address

2017-02-23 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17218

  Issue ID: 17218
   Summary: foreach on tupleof inside switch returns ref to
undefined address
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Severity: minor
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: alex.golt...@gmail.com

```
import std.stdio;

struct S {
int x;
}
S s;
void main() {
foreach (i, ref m; s.tupleof) {
writefln("%s %s, %s", [i], , m);
}
switch (0) {
foreach (i, ref m; s.tupleof) {
case i:
writefln("%s %s, %s", [i], , m);
}
default:
}
}
```

Output:
```
7FAEC3D00260 7FAEC3D00260, 0
7FAEC3D00260 10DBF58F7, 15760771
```

Sometimes it crashes on segmentation fault since it doesn't really copy `m`
where it thinks it is.
Same happens when `s` is `__gshared S s;`.
Reproduces both on `dmd v2.071.0 on OSX` and `ldc2 1.1.0git-3139c87 on linux`.

--