[Issue 18274] va_arg (TypeInfo) broken for static arrays

2018-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18274

Johannes Pfau  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |INVALID

--- Comment #1 from Johannes Pfau  ---
OK, I see that my assumption to get out exactly the same type as passed in was
flawed. If you strictly interpret the passed arguments according to _arguments,
the type of the data changed from static to dynamic array, but the data is
still correct. So this is not really a bug.

--


[Issue 18263] selective import with same name masks out this reference in mixin template

2018-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18263

FeepingCreature  changed:

   What|Removed |Added

   Severity|enhancement |normal

--- Comment #3 from FeepingCreature  ---
Oh, good point - typeof(this).bar fixes the issue.

--


[Issue 18275] New: dmd deletes source file fun.cpp with `dmd fun.cpp.o main.d`

2018-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18275

  Issue ID: 18275
   Summary: dmd deletes source file fun.cpp with `dmd fun.cpp.o
main.d`
   Product: D
   Version: D2
  Hardware: x86
OS: All
Status: NEW
  Severity: critical
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: timothee.co...@gmail.com

```
fun.cpp:extern"C" void test(){}
main.d:extern(C) void test(); void main(){}
```

clang++ -o fun.cpp.o -c fun.cpp
dmd fun.cpp.o main.d

(same bug with ldc2)
this caused https://github.com/Syniurge/Calypso/issues/59

proposed fix:
if `-of` explicitly passed on cmd line, fine, nothing to check

if not, infer output file as we already do, but first assert(!file.exists)
(regardless of what type of file it is, that's irrelevant)

downside:
dmd main2.d
#creates main2
dmd main2.d
#error main2 already exists, please specify -of=main2 explicitly to force write

I think the downside is not as bad as the bug I reported which deletes source
code and can be very damaging if the file wasn't backed up in its latest form,
which is common in edit/compile/debug cycles

--


[Issue 18274] New: va_arg (TypeInfo) broken for static arrays

2018-01-21 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18274

  Issue ID: 18274
   Summary: va_arg (TypeInfo) broken for static arrays
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: druntime
  Assignee: nob...@puremagic.com
  Reporter: johannesp...@gmail.com

This code is currently broken:

https://run.dlang.io/is/68hf1w
-
void foo(...)
{
uint[4] data;
va_arg(_argptr, _arguments[0], );
//data = va_arg!(uint[4])(_argptr);
writeln(data);
}

void main()
{
uint[4] value = [1, 2, 3, 4];
foo(value);
}
-
[4, 0, 3567405808, 32767]

The commented, static variant works. The problem is that DMD passes static
arrays as {.ptr, .length} slice with TypeInfo_Tuple for D variadic functions.
va_arg would have to detect this and instead of just copying the data it has to
dereference the pointer. I'm not sure if this is easily possible though: DMD
passes TypeInfo_Tuple instead of TypeInfo_StaticArray. Can TypeInfo_Tuple only
occur for static arrays? If so, fixing this is easy. If not, we have to pass
proper TypeInfo for static array parameters.

I don't know why we even do this, at least on AArch64 we can have much better
performance by just passing static arrays by value in the same way a struct
would be passed. Passing as ptr+length requires another special case in the
va_arg function for static arrays.

--