[Issue 3245] Easy bug fix available for disabled unit test code in std.encoding

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3245


Andrei Alexandrescu  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||and...@metalanguage.com
 AssignedTo|nob...@puremagic.com|and...@metalanguage.com




--- Comment #1 from Andrei Alexandrescu   2009-08-12 
00:23:37 PDT ---
Terrific, thanks. I looked at that and couldn't figure the problem.

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


[Issue 3246] New: ICE(init.c) using indexed array initializer on local array

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3246

   Summary: ICE(init.c) using indexed array initializer on local
array
   Product: D
   Version: 1.046
  Platform: Other
OS/Version: Windows
Status: NEW
  Keywords: ice-on-invalid-code, patch
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: clugd...@yahoo.com.au


Reported by Ali Cehreli.

void main()
{
int[4] static_1 = [ 3:212 ];
}

PATCH against DMD2.031. We need to make sure the array literal is big enough to
include the last mentioned element.
We need to return ErrorExp, not NULL, otherwise it will still segfault on cases
like int[4] x = [32: 1]; because VerDeclaration::semantic assumes a NULL result
means that it should run semantic on the initializer.

Index: init.c
===
--- init.c(revision 194)
+++ init.c(working copy)
@@ -422,6 +422,13 @@
 else
 edim = value.dim;

+for (size_t i = 0, j = 0; i < value.dim; i++, j++)
+{
+if (index.data[i])
+j = ((Expression *)index.data[i])->toInteger();
+if (j >=edim) edim = j+1;
+}
+
 elements = new Expressions();
 elements->setDim(edim);
 for (size_t i = 0, j = 0; i < value.dim; i++, j++)
@@ -464,7 +471,7 @@
 Lno:
 delete elements;
 error(loc, "array initializers as expressions are not allowed");
-return NULL;
+return new ErrorExp();
 }

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


[Issue 874] Incorrect codegen (?) with tuples, string constants, and AAs

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=874


Don  changed:

   What|Removed |Added

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




--- Comment #2 from Don   2009-08-12 06:17:48 PDT ---
The equivalent code (below) works correctly on D2. This is a D1-only bug.
-
import std.stdio;
template AA(V, K) {
V[K] AA(T...)(T args) {
V[K] ret;
K key;

foreach(i, arg; args) {
static if(!(i & 1))
key = arg;
else
ret[key] = arg;
}
return ret;
}
}
void main()
{
string[string] array = AA!(string, string)("a", "b"[], "c"[], "d"[]);
writefln("length = %d\n", array.length);
foreach(k, v; array)
writefln("array[%d]=%s", k, v);
}

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


[Issue 999] Problem with auto and nested array literals

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=999


Don  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||clugd...@yahoo.com.au
 Resolution||FIXED




--- Comment #3 from Don   2009-08-12 06:37:21 PDT ---
This, the Dstress cases, and the cases in 919, all work in DMD1.045 and 2.030.
(Tested both Windows + Linux).

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


[Issue 3247] New: Crash on overriding class methods with 'auto' return type

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3247

   Summary: Crash on overriding class methods with 'auto' return
type
   Product: D
   Version: 2.031
  Platform: Other
OS/Version: All
Status: NEW
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: jarrett.billings...@gmail.com


class A
{
auto foo() { return 0; }
}

class B : A
{
override auto foo() { return 5; } 
}


The compiler crashes.  It also crashes if A.foo's return type is int or B.foo's
return type is int (but not if both are int, obviously).  It doesn't crash if
foo is not overridden.

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


[Issue 3247] Crash on overriding class methods with 'auto' return type

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3247


Don  changed:

   What|Removed |Added

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




--- Comment #1 from Don   2009-08-12 08:48:53 PDT ---
Is it the same as bug#3042?

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


[Issue 3247] Crash on overriding class methods with 'auto' return type

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3247


Don  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||DUPLICATE




--- Comment #2 from Don   2009-08-12 08:51:45 PDT ---
With my patch for bug #3042 applied, this generates:

bug.d(4): Error: function ice.B.foo of type () overrides but is not covariant w
ith ice.A.foo of type ()

So marking as duplicate.

*** This issue has been marked as a duplicate of issue 3042 ***

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


[Issue 3042] Segfault on incorrect override

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3042


Don  changed:

   What|Removed |Added

 CC||jarrett.billings...@gmail.c
   ||om




--- Comment #2 from Don   2009-08-12 08:51:45 PDT ---
*** Issue 3247 has been marked as a duplicate of this issue. ***

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


[Issue 3248] New: lossless floating point formatting

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3248

   Summary: lossless floating point formatting
   Product: D
   Version: unspecified
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: moi...@hotmail.com


Could an option be added to the formatting to elide trailing zero's for %f ?
That way it is possible to create an optimal lossless formatting for which the
following holds:

float f;
s = format(f);
float f2 = to!(float)(s);
assert(f==f2);

The formatting I'm trying to get can be seen here (decimal):
http://www.h-schmidt.net/FloatApplet/IEEE754.html

%g fails to format like this because it uses %f for as small as 10^-5,
thus loosing precision for floats with leading zero's, like 0.1234567.

Fixing this by using %f for 10^-5..10^-1 fails because it doesn't elide
trailing zero's making it suboptimal space-wise. 

It would be even nicer to have this lossless formatting added to std.format!
I would even suggest making this the default formatting for floating point;
floating point isn't as straight forward as integral and it is easy to think
the current formatting holds all information.

Compared to the hex %a format this new lossless format will be better readable
(less bug-prone) and generally shorter (0.1 will be 0.1).

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


[Issue 928] nested struct definition in unittest section of a templated class, hangs DMD

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=928


Don  changed:

   What|Removed |Added

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




--- Comment #2 from Don   2009-08-12 11:29:31 PDT ---
Straightforward patch. This is just a copy-and-paste of the code for the other
recursive template expansion checks.
Patch against DMD 2.031.

Index: template.c
===
--- template.c(revision 194)
+++ template.c(working copy)
@@ -3592,7 +3592,27 @@

 if (sc->func || dosemantic3)
 {
+#if WINDOWS_SEH
+  __try
+  {
+#endif
+if (++nest > 500)
+{
+global.gag = 0;// ensure error message gets printed
+error("recursive expansion");
+fatal();
+}
 semantic3(sc2);
+--nest;
+#if WINDOWS_SEH
+  }
+  __except (__ehfilter(GetExceptionInformation()))
+  {
+global.gag = 0;// ensure error message gets printed
+error("recursive expansion");
+fatal();
+  }
+#endif
 }

   Laftersemantic:

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


[Issue 3101] Stack overflow: declaring aggregate member twice with static if

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3101


Don  changed:

   What|Removed |Added

   Keywords||patch




--- Comment #3 from Don   2009-08-12 11:26:48 PDT ---
Patch is very easy.

in int AliasDeclaration::overloadInsert(Dsymbol *s), make sure it doesn't call
itself.


Index: declaration.c
===
--- declaration.c(revision 194)
+++ declaration.c(working copy)
@@ -543,6 +543,8 @@
 {overnext = s;
 return TRUE;
 }
+else if (overnext==this) // a recursive expansion would ensue. Bugzilla
3101
+   return FALSE;
 else
 {
 return overnext->overloadInsert(s);

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


[Issue 3248] lossless floating point formatting

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3248


Don  changed:

   What|Removed |Added

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




--- Comment #1 from Don   2009-08-12 12:22:26 PDT ---
It's not that easy, actually. When should it print 0.0, and
when should it print 0.1 ? The code to do it correctly is amazingly
complicated.
Just be aware that what you're asking for is much more difficult than you
probably imagine.

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


[Issue 3248] lossless floating point formatting

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3248





--- Comment #2 from assorted   2009-08-12 15:40:10 PDT ---
(In reply to comment #1)
> It's not that easy, actually. When should it print 0.0, and
> when should it print 0.1 ? The code to do it correctly is amazingly
> complicated.
> Just be aware that what you're asking for is much more difficult than you
> probably imagine.

It is less difficult than you imagine :)

Lets take floats:

A float has at most 24bits of precision

2^-24 = 0.00059604644775390625
2^-23 = 0.0011920928955078125

to distinguish between these two you only need a precision of 8.

Thus %.8e will always be lossless but isn't always the nicest way of
representation. %g fixes this by using %f if the exponent for an e format is
greater than -5 and less than the precision. The less than precision part is
correct, but the greater than 10^-5 is bad as the precision specifies the
number of digits generated after the decimal point; not excluding leading
zeros.
If %g would be changed to use %f only between 10^-1 and precision that would
solve that problem, if %f were to elide trailing zeros.

Back to the 0.1 question. 0.1 is actually saved as 0.100012...
Eliding trailing zeros from %f.8 would be sufficient to get 0.1

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


[Issue 3249] New: sort and setIntersection on array of struct or class

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3249

   Summary: sort and setIntersection on array of struct or class
   Product: D
   Version: 2.031
  Platform: x86
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: jesse.k.phillip...@gmail.com
CC: jesse.k.phillip...@gmail.com


If you create an array of struct or class, sorting does not work for
std.algorthm.sort

The error from using sort:

C:\opt\dmd\windows\bin\..\..\src\phobos\std\algorithm.d(3620): Error:
static assert  "Invalid predicate passed to sort: a < b"

The error from using setIntersection:

C:\opt\dmd\windows\bin\..\..\src\phobos\std\functional.d(191): Error:
static assert  "Bad binary function q{a < b}. You need to use a valid D
expression using symbols a of type S and b of type S."

The code used:

import std.algorithm;
import std.stdio;

struct S {
string label;

int opCmp(S s2) {
if(label < s2.label)
return -1;
if(label > s2.label)
return 1;
else return 0;
}
}

void main() {
auto s1 = new S[2];
auto s2 = new S[2];

s1[0].label = "fish";
s1[1].label = "bar";
s2[0].label = "foo";
s2[1].label = "fish";

// Comment out to get setInterseciton error
sort(s1);

foreach(str; setIntersection(s1,s2))
writeln(str);
}

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


[Issue 3249] sort and setIntersection on array of struct or class

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3249


Andrei Alexandrescu  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||and...@metalanguage.com
 AssignedTo|nob...@puremagic.com|and...@metalanguage.com




--- Comment #1 from Andrei Alexandrescu   2009-08-12 
16:21:53 PDT ---
This is because the default comparison is passed as a string, which does not
see the definition of the struct. I'll change that to a function.

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


[Issue 3248] lossless floating point formatting

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3248


Stewart Gordon  changed:

   What|Removed |Added

 CC||s...@iname.com




--- Comment #3 from Stewart Gordon   2009-08-12 18:21:21 PDT ---
I can see a few possible approaches to lossless floating point formatting:

(a) decimal with infinite precision, minus trailing zeros
(b) minimum number of significant figures guaranteed to be unique, minus
trailing zeros
(c) the shortest possible string that, when parsed as a floating point, is
exactly this number

(a) clearly isn't what the reporter is asking for.

(b) seems straightforward.  (Is the number of s.f. in question just the .dig
property?)

(c) is optimal, and could probably be implemented quite simply (not sure
whether it would be most efficient though) with the aid of the nextUp and
nextDown functions.  This would also address the question in comment 1, though
I'm not sure how easy it would be to implement this efficiently.

But (b) and (c) are ambiguous: do we go by uniqueness/exactitude in the real
type or in the actual floating point type being used?  I can see that sometimes
the app'll know what type it will later be read into, and sometimes it won't.

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


[Issue 3248] lossless floating point formatting

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3248





--- Comment #4 from assorted   2009-08-12 19:45:28 PDT ---
As far as I understand it, removing trailing zeros from .8 precision and (c)
are the same.
This is because the first (right to left) non-zero you encounter is there
because of 2^x.

I actually used nextUp to test a few ranges of floats :) (I have a not so fast
computer) 

I remember .dig being 6 for all floats (could be wrong here, not close to any
dmd.exe)

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


[Issue 3248] lossless floating point formatting

2009-08-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3248


Andrei Alexandrescu  changed:

   What|Removed |Added

 CC||and...@metalanguage.com




--- Comment #5 from Andrei Alexandrescu   2009-08-12 
22:43:37 PDT ---
I recommend anyone interested in the subject to peruse the papers:

"How to Read Floating Point Numbers Accurately"
ftp://ftp.ccs.neu.edu/pub/people/will/howtoread.ps

and

"Printing Floating-Point Numbers Quickly and Accurately"
www.cs.indiana.edu/~burger/FP-Printing-PLDI96.pdf

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