[Issue 15768] std.stdio.trustedStdout accesses __gshared data without synchronization.

2016-06-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15768

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

https://github.com/dlang/phobos/commit/92eed4f45ed01a5d1f975fb23859ea63473e6f5e
Warn about Issue 15768

https://github.com/dlang/phobos/commit/02d1aedf6d3d001989ee342eae6d9fc6db61d399
Merge pull request #4401 from JackStouffer/patch-9

Warn about Issue 15768

--


[Issue 16120] New: dmd does not inline simple range primitives

2016-06-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16120

  Issue ID: 16120
   Summary: dmd does not inline simple range primitives
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: greensunn...@gmail.com

observation 1) dmd doesn't inline range primitives (it's 8x slower!)
observation 2) foreach with direct random access is lower in dmd (30%)

simple benchmark yields

```
> dmd -release -O foo.d && ./foo
0 881 ms, 351 μs, and 9 hnsecs
1 685 ms, 888 μs, and 4 hnsecs
2 685 ms, 654 μs, and 4 hnsecs
3 7 secs, 211 ms, 530 μs, and 3 hnsecs
```

for:

auto f_random_access(R)(R r)
{
auto sum = 0;
foreach (const i; 0 .. r.length)
{
sum += r[i];
}
return sum;
}

auto f_foreach(R)(R r)
{
auto sum = 0;
foreach (const el; r)
{
sum += el;
}
return sum;
}

auto f_foreach_ref(R)(R r)
{
auto sum = 0;
foreach (const ref el; r)
{
sum += el;
}
return sum;
}

auto f_for(R)(R r)
{
import std.range;
auto sum = 0;
for (r.popFront(); !r.empty; r.popFront())
{
sum += r.front;
}
return sum;
}

void main() {
import std.datetime: benchmark, Duration;
import std.stdio: writeln;
import std.array: array;
import std.conv: to;
import std.random: randomShuffle;
import std.range:iota;
auto arr = iota(100_000).array;
arr.randomShuffle;

auto i = 0;

void f0(){ i += arr.f_random_access; }
void f1(){ i += arr.f_foreach; }
void f2(){ i += arr.f_foreach_ref; }
void f3(){ i += arr.f_for; }
auto rs = benchmark!(f0, f1, f2, f3)(10_000);
foreach(j,r;rs)
writeln(j, " ", r.to!Duration);

// prevent any optimization
writeln(i);
}

--


[Issue 12558] try/catch allows implicit catching of Errors without specifying any Exception type

2016-06-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12558

--- Comment #15 from Andrei Alexandrescu  ---
Yes, catching Errors should always be explicit.

--


[Issue 16121] New: the canonical way to create and use an exception type is not documented on dlang.org

2016-06-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16121

  Issue ID: 16121
   Summary: the canonical way to create and use an exception type
is not documented on dlang.org
   Product: D
   Version: D2
  Hardware: All
   URL: http://dlang.org/
OS: All
Status: NEW
  Severity: enhancement
  Priority: P3
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: poliklosio.dl...@gmail.com

As a new D user I need basic information, for example if an exception should be
a class or struct, what class it should inherit from, and what is a good or
typical way to pass exception message in D. 
An example that I can easily spot and analyze would be by far the best way to
provide this.

I've been searching for this but could not find such example.
When I search for "dlang exception handling", the first page that google
redirects me to is:
https://dlang.org/spec/errors.html
It doesn't contain the needed info.
Then I tried to navigate manually to a page that should contain the
information. I landed on:
https://dlang.org/exception-safe.html
No luck there either.

--


[Issue 16121] the canonical way to create and use an exception type is not documented on dlang.org

2016-06-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16121

ag0ae...@gmail.com changed:

   What|Removed |Added

 CC||ag0ae...@gmail.com

--- Comment #1 from ag0ae...@gmail.com ---
(In reply to Piotr from comment #0)
> As a new D user I need basic information, for example if an exception should
> be a class or struct, what class it should inherit from,
> and what is a good
> or typical way to pass exception message in D. 
> An example that I can easily spot and analyze would be by far the best way
> to provide this.

Must be a class that inherits from Throwable. And usually you inherit from
Exception.

> I've been searching for this but could not find such example.
> When I search for "dlang exception handling", the first page that google
> redirects me to is:
> https://dlang.org/spec/errors.html
> It doesn't contain the needed info.
> Then I tried to navigate manually to a page that should contain the
> information. I landed on:
> https://dlang.org/exception-safe.html
> No luck there either.

One page you should be able to find is this:
https://dlang.org/library/object/exception.html

I agree that there should be a document describing the matter. Maybe there is
and we both just can't find it.

--


[Issue 16122] New: user-friendly CLI interface for dmd

2016-06-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16122

  Issue ID: 16122
   Summary: user-friendly CLI interface for dmd
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: greensunn...@gmail.com

tl;dr: I couldn't find a found to set the output file of dmd. Tested with 2.071
and git master

> dmd test.d -o bin/test

Error: -o no longer supported, use -of or -od

> dmd test_save.d -of=bin/test


> dmd test_save.d -of bin/test

Error: argument expected for switch '-of'

> dmd test_save.d -of=bin/test

creates '=bin/test'

> dmd test_save.d -od=bin -of=test

creates folder '=bin'
and binary '=test' (in current directory)

Documentation says:

-odobjdir
write object files relative to directory objdir instead of to the current
directory. -op can be used if the original package hierarchy should be retained
-offilename
Set output file name to filename in the output directory. The output file can
be an object file, executable file, or library file depending on the other
switches.

.. so of course I now feel silly, but then again - can't we have a user
friendly CLI?

--


[Issue 16123] New: alias member of member

2016-06-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16123

  Issue ID: 16123
   Summary: alias member of member
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: schvei...@yahoo.com

Currently, you can alias a member of your struct no problem:

struct S
{
   int x;
   alias y = x;
}

If I want to alias a member of a member, it does not work:

struct T
{
   S s;
   alias y = s.x; // note, this compiles just fine, you need to use it to flag
the error.
}

void main()
{
   T t;
   t.s.y = 5; // ok
   t.y = 5; // Error: need 'this' for 'x' of type 'int'
}

To me, this doesn't make sense. The requirements shouldn't be any different, if
I can alias a member, I should be able to alias a member's member, especially
if the member is a field.

I'm not sure if this is an enhancement or a bug. Flagging as bug, change if
necessary.

Note, in older versions of the compiler (2.069 and earlier), I get an
additional error:

Error: struct testalias.T 'x' is not a member

--


[Issue 16123] alias member of member

2016-06-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16123

Ketmar Dark  changed:

   What|Removed |Added

 CC||ket...@ketmar.no-ip.org

--