[Issue 5568] A problem with BigInt modulus

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5568


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

 CC||clugd...@yahoo.com.au


--- Comment #2 from Don clugd...@yahoo.com.au 2011-02-13 00:20:33 PST ---
(In reply to comment #1)
 Problem originally found by tsukikage.
 
 A handy printing function for BigInts is really needed in Phobos.

Have you tried writefln?

import std.stdio;
import std.bigint;

void main()
{
BigInt a = 7;
a ^^=56;
writefln(%x, a);
writefln(%s, a);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705



--- Comment #6 from bearophile_h...@eml.cc 2011-02-13 05:51:55 PST ---
Two more usage examples of the improved max. This program finds the longest
common subsequence with a recursive algorithm:


import std.stdio;
T[] lcs(T)(T[] a, T[] b) {
T[] longest(T)(T[] s, T[] t) {
return s.length  t.length ? s : t;
}
if (!a.length || !b.length)
return null;
if (a[0] == b[0])
return a[0] ~ lcs(a[1..$], b[1..$]);
return longest(lcs(a, b[1..$]), lcs(a[1..$], b));
}
void main() {
writeln(lcs(thisisatest, testing123testing));
}


With a key-mapping max() you are able to remove the inner function and simplify
the code (untested):

import std.stdio;
T[] lcs(T)(T[] a, T[] b) {
if (!a.length || !b.length)
return null;
if (a[0] == b[0])
return a[0] ~ lcs(a[1..$], b[1..$]);
return max!q{a.length}([lcs(a, b[1..$]), lcs(a[1..$], b)]);
}
void main() {
writeln(lcs(thisisatest, testing123testing));
}


--

This program shows the most common anagrams from a dictionary file of different
words:


import std.stdio, std.algorithm;
void main() {
string[][string] anags;
foreach (w; File(unixdict.txt).byLine())
anags[w.sort.idup] ~= w.idup;
int m = reduce!max(map!q{a.length}(anags.values));
writeln(filter!((wl){ return wl.length == m; })(anags.values));
}


A key-mapping max() makes the code shorter and more readable (untested):


import std.stdio, std.algorithm;
void main() {
string[][string] anags;
foreach (w; File(unixdict.txt).byLine())
anags[w.sort.idup] ~= w.idup;
int m = max!q{a.length}(anags.values);
writeln(filter!((wl){ return wl.length == m; })(anags.values));
}


maxs() simplifies the code even more (untested):

import std.stdio, std.algorithm;
void main() {
string[][string] anags;
foreach (w; File(unixdict.txt).byLine())
anags[w.sort.idup] ~= w.idup;
writeln(maxs!q{a.length}(anags.values));
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5568] A problem with BigInt modulus

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5568



--- Comment #4 from Don clugd...@yahoo.com.au 2011-02-13 07:24:38 PST ---
(In reply to comment #3)
 (In reply to comment #2)
 
  Have you tried writefln?
  
  import std.stdio;
  import std.bigint;
  
  void main()
  {
  BigInt a = 7;
  a ^^=56;
  writefln(%x, a);
  writefln(%s, a);
  }
 
 I have never tried that. I suggest to add this example to docs of the
 std.bigint module :-)

Yes, although I think it's pretty obvious. The non-obvious thing, is that if
you tried in on 2.050 or earlier, it didn't work... It does now.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4014] CodeView debug type info not linked in from library

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4014


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |


--- Comment #3 from Walter Bright bugzi...@digitalmars.com 2011-02-13 
11:41:55 PST ---
Rainer Schuetze writes on the mailing list:

trying to create a branch with as little changes to the master branch as
possible, I noticed that this patch causes problems when creating DLLs (it
still wants _Dmain to be defined). This is happening because the patch puts
full modules into a library instead of single functions when also adding debug
symbols, so any reference into rt.dmain2 drags in the standard console
application startup. My patches to create a shared version of the runtime
library split this module, so the issue did not show up before.

I'd say the patch to 4014 should be reverted until this is sorted out. A minor
improvement could be that prohibiting multiobj generation should be limited to
debug builds in addition to adding debug symbols (which could also happen for
release builds).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4329] Do not show error messages that refer to __error

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4329



--- Comment #15 from Don clugd...@yahoo.com.au 2011-02-13 12:46:19 PST ---
Original D1 case is patched here:
https://github.com/donc/dmd/commit/1acd2b64b10c4a985a10750d5ad83a0b7e98332b
Other cases patched for D2:
https://github.com/donc/dmd/commit/3a512771e31de4fb8b4e806154b08766fd97aed1
and for D1:
https://github.com/donc/dmd/commit/327afade5bfe0551176ee17ab6c991139dcb8058

Another test case from bug 5288:
auto bug4329e(int z) {
if (z) return undefined;
else return 0;
}
fixed here:
https://github.com/donc/dmd/commit/daff978816461602788f1cb396d9826918b6da21

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2479] Cannot use variadic arguments inside a closure

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2479


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

Summary|Regression: cannot use  |Cannot use variadic
   |variadic arguments inside a |arguments inside a closure
   |closure |
   Severity|regression  |normal


--- Comment #11 from Don clugd...@yahoo.com.au 2011-02-13 12:53:56 PST ---
Removing the 'regression' keyword, since variadic arguments in closures have
never worked.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5348] Variable Length Arrays

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5348



--- Comment #3 from bearophile_h...@eml.cc 2011-02-13 12:58:28 PST ---
Ada language too supports stack-allocation of 2D arrays with run-time sizes, an
example:


with Ada.Text_Io; use Ada.Text_Io;
with Ada.Float_Text_Io; use Ada.Float_Text_Io;
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;

procedure Two_Dimensional_Arrays is
   type Matrix_Type is array(Positive range , Positive range ) of Float;
   Dim_1 : Positive;
   Dim_2 : Positive;
begin
   Get(Item = Dim_1);
   Get(Item = Dim_2);
   -- Create an inner block with the correctly sized array
   declare
  Matrix : Matrix_Type(1..Dim_1, 1..Dim_2);
   begin
  Matrix(1, Dim_2) := 3.14159;
  Put(Item = Matrix(1, Dim_2), Fore = 1, Aft = 5, Exp = 0);
  New_Line;
   end;
   -- The variable Matrix is popped off the stack automatically
end Two_Dimensional_Arrays;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5569] New: 64 bit Dwarf symbolic debug info not recognized by gdb

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5569

   Summary: 64 bit Dwarf symbolic debug info not recognized by gdb
   Product: D
   Version: D1  D2
  Platform: x86_64
OS/Version: Linux
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bugzi...@digitalmars.com


--- Comment #0 from Walter Bright bugzi...@digitalmars.com 2011-02-13 
15:05:45 PST ---
I haven't figured out what's wrong with it yet. Any help would be appreciated.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5570] New: 64 bit C ABI not followed for passing structs and complex numbers as function parameters

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5570

   Summary: 64 bit C ABI not followed for passing structs and
complex numbers as function parameters
   Product: D
   Version: D1  D2
  Platform: x86_64
OS/Version: Linux
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bugzi...@digitalmars.com


--- Comment #0 from Walter Bright bugzi...@digitalmars.com 2011-02-13 
15:08:20 PST ---
They are always pushed on the stack rather than sometimes being passed in
registers. Haven't got to fixing this yet.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5571] New: [64-bit] new bool returns bogus address

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5571

   Summary: [64-bit] new bool returns bogus address
   Product: D
   Version: D2
  Platform: x86_64
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: dsim...@yahoo.com


--- Comment #0 from David Simcha dsim...@yahoo.com 2011-02-13 16:23:24 PST ---
import std.stdio;

void main() {
auto b = new bool;
stderr.writeln(b);
*b = false;
}

The address I receive can't be right because it's in no-man's land part of
x64 address space, at least according to http://en.wikipedia.org/wiki/X86-64 . 
At any rate, it segfaults the program.

AD7DAE80
Segmentation fault

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4088] opEquals not called on interfaces

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4088



--- Comment #2 from d...@dawgfoto.de 2011-02-13 16:49:22 PST ---
Created an attachment (id=907)
Proposed fix

It is actually a very surprising bug, that interfaces can't be compared as it
might break structs due to the compiler generated opEquals.
The attached patch does an explicit cast to Object.
This would still not work with C++/COM interfaces.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5571] [64-bit] new bool returns bogus address

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5571



--- Comment #1 from David Simcha dsim...@yahoo.com 2011-02-13 17:02:22 PST ---
Looking into it further, this seems to happen with any primitive type, for
example, new double, new uint.  Amazingly, though, this code works:

import std.stdio;

void main() {
auto b = (new bool[1]).ptr;
stderr.writeln(b);
*b = 1;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4833] dmd -od doesn't make it to optlink's command line for map files

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4833


Brad Roberts bra...@puremagic.com changed:

   What|Removed |Added

   Keywords||patch
   Platform|Other   |All
 AssignedTo|nob...@puremagic.com|bugzi...@digitalmars.com
 OS/Version|Windows |All


--- Comment #1 from Brad Roberts bra...@puremagic.com 2011-02-13 17:12:41 PST 
---
https://github.com/D-Programming-Language/dmd/pull/6

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4750] fail_compilation/fail225.d causes dmd to segv

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4750



--- Comment #4 from Brad Roberts bra...@puremagic.com 2011-02-13 17:36:48 PST 
---
I just re-tried this one.  It still fails on linux but not on windows.  Odd.

#0  0x080b5f22 in Type::isImmutable (this=0x0) at mtype.h:256
#1  0x08134fbb in Type::invariantOf (this=0x0) at mtype.c:383
#2  0x08136cc3 in Type::castMod (this=0x0, mod=4) at mtype.c:1079
#3  0x080538b5 in StructLiteralExp::implicitConvTo (this=0x8250da8,
t=0x8255a18) at cast.c:429
#4  0x080b3bb7 in VarDeclaration::semantic (this=0x821edd0, sc=0x8255730) at
declaration.c:1175
#5  0x080e089f in DeclarationExp::semantic (this=0x821ee78, sc=0x8255620) at
expression.c:4707
#6  0x0816b76a in ExpStatement::semantic (this=0x821ee60, sc=0x8255620) at
statement.c:256
#7  0x0816c36e in CompoundStatement::semantic (this=0x821eea8, sc=0x8255620) at
statement.c:483
#8  0x080fd84a in FuncDeclaration::semantic3 (this=0x821e918, sc=0x8255590) at
func.c:1239
#9  0x081333b2 in Module::semantic3 (this=0x821e1d8) at module.c:859
#10 0x08130884 in main (argc=13, argv=0x8214510) at mars.c:1204

#3  0x080538b5 in StructLiteralExp::implicitConvTo (this=0x8250da8,
t=0x8255a18) at cast.c:429
429 te = te-castMod(t-mod)

te is null
e-toChars() -- ch

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5572] New: [64-bit] Global Hidden Mutexes Seem to share Addresses W/ Global Variables

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5572

   Summary: [64-bit] Global Hidden Mutexes Seem to share Addresses
W/ Global Variables
   Product: D
   Version: D2
  Platform: x86_64
OS/Version: Windows
Status: NEW
  Keywords: wrong-code
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: dsim...@yahoo.com


--- Comment #0 from David Simcha dsim...@yahoo.com 2011-02-13 18:43:48 PST ---
Apparently global gets overwritten when the synchronized block is entered in
the following code:

import std.stdio;

void doSynchronized() {
stderr.writeln(In doSynchronized() 1:  , cast(void*) global);
synchronized {
stderr.writeln(In doSynchronized() 2:  , cast(void*) global);
}
}

__gshared Object global;

void main() {
auto local = new Object;
global = local;

stderr.writeln(In main() 1:  ,
cast(void*) global, '\t', cast(void*) local);
doSynchronized();
stderr.writeln(In main() 2:  ,
cast(void*) global, '\t', cast(void*) local);

}

Output:

In main() 1:  7F4E605D8E707F4E605D8E70
In doSynchronized() 1:  7F4E605D8E70
In doSynchronized() 2:  0
In main() 2:  07F4E605D8E70

Happens only in 64-bit mode.  -O, -inline and -release flags seem to be
irrelevant.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5571] [64-bit] new bool returns bogus address

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5571


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||FIXED


--- Comment #2 from Walter Bright bugzi...@digitalmars.com 2011-02-13 
20:42:26 PST ---
https://github.com/D-Programming-Language/dmd/commit/17a2a204f41039029f2e29ec33a8e66197557540

https://github.com/D-Programming-Language/dmd/commit/15005056cf21090c3572a81e8a3db492e7b923d8

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4750] fail_compilation/fail225.d causes dmd to segv

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4750



--- Comment #5 from Brad Roberts bra...@puremagic.com 2011-02-13 21:08:41 PST 
---
Ok, te is null in windows as well, but for whatever reason, it's not seg
faulting.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4750] fail_compilation/fail225.d causes dmd to segv

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4750


Brad Roberts bra...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 AssignedTo|nob...@puremagic.com|bugzi...@digitalmars.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4750] fail_compilation/fail225.d causes dmd to segv

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4750



--- Comment #6 from Brad Roberts bra...@puremagic.com 2011-02-13 21:47:33 PST 
---
Created an attachment (id=908)
fix a few error handling paths

Several of the error paths in StructInitializer::semantic fail to set errors
which can lead to continuing to work with half built objects.

I'm not sure this is the right fix, but it does fix the segv produced by the
dmd failure test fail225.d and doesn't break any existing tests.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4750] fail_compilation/fail225.d causes dmd to segv

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4750



--- Comment #7 from Brad Roberts bra...@puremagic.com 2011-02-13 21:51:23 PST 
---
see also: https://github.com/D-Programming-Language/dmd/pull/8

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5572] [64-bit] Global Hidden Mutexes Seem to share Addresses W/ Global Variables

2011-02-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5572


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||FIXED


--- Comment #1 from Walter Bright bugzi...@digitalmars.com 2011-02-13 
21:59:53 PST ---
https://github.com/D-Programming-Language/dmd/commit/8b008da60a01bb11721943f92dffe2cf38ea1a3d

https://github.com/D-Programming-Language/dmd/commit/2adc2e2e34a625324fe2e45d43e4d7ae84299291

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---