[Issue 3974] ICE(init.c): Static array initializer with more elements than destination array

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3974


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

   What|Removed |Added

   Keywords||patch


--- Comment #2 from Don clugd...@yahoo.com.au 2010-04-09 13:35:44 PDT ---
Note to bearophile: The case where the number of elements is LESS than the
array size (bug 3849) is quite different. Note that, for example,
int [3] x = [ 2: 15]; is currently legal.

This patch is slightly more general, in that it covers the cases like
  int[3] toomany = [ 2: 13, 1];

PATCH: init.c line 343 (in ArrayInitializer::semantic()).


if (length == 0)
error(loc, array dimension overflow);
if (length  dim)
dim = length;
}

+if (t-ty == Tsarray)
+{
+size_t edim = ((TypeSArray *)t)-dim-toInteger();
+if (dim  edim)
+{
+error(loc, array initializer has %d elements, but array length is
%d, dim, edim);
+return new ExpInitializer(loc, new ErrorExp());
+}
+}
unsigned long amax = 0x8000;
if ((unsigned long) dim * t-nextOf()-size() = amax)
error(loc, array dimension %u exceeds max of %ju, dim, amax /
t-nextOf()-size());

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


[Issue 3920] Assertion failure: '0' on line 10018 in file 'expression.c'

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3920


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #3 from Don clugd...@yahoo.com.au 2010-04-09 13:39:13 PDT ---
Fixed DMD1.058 and 2.043.

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


[Issue 3919] ICE(expression.c, 9944): * or / with typedef ireal

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3919


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #3 from Don clugd...@yahoo.com.au 2010-04-09 13:40:06 PDT ---
Fixed DMD1.058 and 2.042.

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


[Issue 3884] Segfault: defining a typedef with an invalid object.d

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3884


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #5 from Don clugd...@yahoo.com.au 2010-04-09 13:40:48 PDT ---
Fixed DMD1.058 and 2.043.

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


[Issue 3842] ICE(expression.c) using pointer in CTFE

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3842


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #1 from Don clugd...@yahoo.com.au 2010-04-09 13:41:25 PDT ---
Fixed DMD1.058 and 2.043.

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


[Issue 3808] Assertion Failure : Assertion failure: 'classinfo-structsize == CLASSINFO_SIZE' on line 870 in file 'toobj.c'

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3808


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #5 from Don clugd...@yahoo.com.au 2010-04-09 13:41:54 PDT ---
Fixed DMD1.058 and 2.043.

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


[Issue 3984] Segfault(interpret.c): CTFE using struct constructor on a local static variable

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3984


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #3 from Don clugd...@yahoo.com.au 2010-04-09 13:42:41 PDT ---
Fixed DMD1.058 and 2.043.

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


[Issue 4072] Stack overflow on recursive template expansion inside contract

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4072


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #2 from Don clugd...@yahoo.com.au 2010-04-09 13:43:37 PDT ---
Fixed DMD2.043.

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


[Issue 3972] Regarding module with name different from its file name

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3972



--- Comment #6 from bearophile_h...@eml.cc 2010-04-09 14:53:02 PDT ---
After a short discussion with Walter it seems that in D it's OK to have a file
named foo.d with inside it at the top written module bar;.
The rationale behind it is The flexibility comes in handy now and then..

So probably there's no interest in fixing this small umpteenth hole in the
module system.

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


[Issue 122] DDoc newline behaviour produces suboptimal results

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=122


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #6 from Don clugd...@yahoo.com.au 2010-04-09 19:07:34 PDT ---
Fixed DMD1.058 and DMD2.043.

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


[Issue 1628] Ddoc produces invalid documentation for --- blocks

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1628


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #4 from Don clugd...@yahoo.com.au 2010-04-09 19:08:05 PDT ---
Fixed DMD1.058 and DMD2.043.

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


[Issue 2609] No documentation generated for destructor

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2609


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #5 from Don clugd...@yahoo.com.au 2010-04-09 19:10:22 PDT ---
Fixed DMD1.058 and DMD2.043.

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


[Issue 3885] No multithread support for Windows DLL

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3885


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

   What|Removed |Added

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


--- Comment #4 from Don clugd...@yahoo.com.au 2010-04-09 19:12:47 PDT ---
Fixed DMD1.058 and DMD2.042.

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


[Issue 3899] CTFE: poor error message for use of uninitialized variable

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3899


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #2 from Don clugd...@yahoo.com.au 2010-04-09 19:13:24 PDT ---
Fixed DMD1.058 and DMD2.042.

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


[Issue 3900] CTFE: Wrong return value for array.var assignment

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3900


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #2 from Don clugd...@yahoo.com.au 2010-04-09 19:14:05 PDT ---
Fixed DMD1.058 and DMD2.042.

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


[Issue 3901] PATCH: Nested struct assignment for CTFE

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3901


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #5 from Don clugd...@yahoo.com.au 2010-04-09 19:14:41 PDT ---
Fixed DMD1.058 and DMD2.042.

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


[Issue 3914] Struct as argument that fits in register has member accessed wrong

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3914


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #4 from Don clugd...@yahoo.com.au 2010-04-09 19:15:20 PDT ---
Fixed DMD1.058 and DMD2.042.

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


[Issue 3958] mixin(non-static method) crashes compiler

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3958


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #4 from Don clugd...@yahoo.com.au 2010-04-09 13:38:29 PDT ---
Fixed DMD1.048 and 2.043.

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


[Issue 4004] DMD 2.042 CTFE regression with functions taking ref parameters

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4004


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


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


[Issue 4011] Incorrect function overloading using mixins

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4011


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

   What|Removed |Added

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


--- Comment #2 from Don clugd...@yahoo.com.au 2010-04-09 19:18:24 PDT ---
Fixed DMD1.058 and DMD2.043.

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


[Issue 4019] [CTFE] Adding an item to an empty AA

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4019


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

   What|Removed |Added

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


--- Comment #2 from Don clugd...@yahoo.com.au 2010-04-09 19:20:38 PDT ---
Fixed DMD1.058 and DMD2.043.

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


[Issue 4027] Closures in CTFE generate wrong code

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4027


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #3 from Don clugd...@yahoo.com.au 2010-04-09 19:21:30 PDT ---
Fixed DMD2.043.

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


[Issue 4029] CTFE: cannot invoke delegate returned from function

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4029


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #2 from Don clugd...@yahoo.com.au 2010-04-09 19:22:03 PDT ---
Fixed DMD1.058 and DMD2.043.

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


[Issue 4023] std.math.hypot() returns infinity when either argument is zero

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4023


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

   What|Removed |Added

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


--- Comment #1 from Don clugd...@yahoo.com.au 2010-04-09 19:23:21 PDT ---
Fixed DMD2.043.

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


[Issue 3342] TLS on dynamically loaded DLLs fails on Windows earlier than Vista

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3342


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #5 from Don clugd...@yahoo.com.au 2010-04-09 19:36:55 PDT ---
Fixed DMD2.042, documentation fixed in 2.043.

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


[Issue 4076] New: Wrong error line number with enum

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4076

   Summary: Wrong error line number with enum
   Product: D
   Version: future
  Platform: x86
OS/Version: Windows
Status: NEW
  Keywords: diagnostic
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-09 19:57:53 PDT ---
This is wrong D2 code:

void main() {
enum double n = 10;
// *
// *
// *
auto arr = new int[n];
}


dmd 2.043 prints:

test.d(2): Error: cannot implicitly convert expression (10) of type double to
uint

Note the line number of the error. It says 2 and not 6.
If the enum is far away from the line where arr is defined, it's not easy to
understand, find, and fix the bug in the code.

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


[Issue 2085] CTFE fails if the function is forward referenced

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2085



--- Comment #4 from Don clugd...@yahoo.com.au 2010-04-10 11:31:33 PDT ---
Although bug 4075 appears similar to this one, the patch doesn't fix it.

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


[Issue 3986] Struct constructors bypass default initialization of member variables

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3986


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #3 from Don clugd...@yahoo.com.au 2010-04-10 12:45:32 PDT ---
Fixed DMD2.043.

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


[Issue 3863] Various errors and ICEs for struct constructors with ellipses

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3863


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

   What|Removed |Added

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


--- Comment #2 from Don clugd...@yahoo.com.au 2010-04-10 13:55:43 PDT ---
The first step is to turn the segfaults into an ICE:
todt.c, line 59.

dt_t *VoidInitializer::toDt()
{   /* Void initializers are set to 0, just because we need something
 * to set them to in the static data segment.
 */
dt_t *dt = NULL;
+assert(type);
dtnzeros(dt, type-size());
return dt;
}

I haven't been able to reproduce the other ICE (todt.c 688) on either 2.043,
2.040, or 2.041.

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


[Issue 2962] ICE(glue.c) or bad codegen passing variable as template value parameter

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2962


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

   What|Removed |Added

   Severity|major   |critical


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


[Issue 4077] New: Bugs caused by bitwise operator precedence

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4077

   Summary: Bugs caused by bitwise operator precedence
   Product: D
   Version: future
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-10 16:06:32 PDT ---
This isn't a bug report, and it's not exactly an enhancement request yet. It's
a report that a problem exists, but I don't know a solution yet. I think it's
useful to have this in Bugzilla, to keep in mind that this problem exists in D.

This report is born from a bug done by Adam D. Ruppe, but similar bugs have
happened in my code too in the past:

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.Darticle_id=108772
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.Darticle_id=108781
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.Darticle_id=108783

The precedence of bitwise operators is low, this makes them error-prone, it's a
part of C/C++/D that causes frequent bugs in programs (the solution is to 
extra parentheses when you use bitwise operators). At the moment I don't see a
simple way to remove this source of bugs from the D2 language.

This class of bugs is so common that GCC developers have felt the need to
improve the situation. When you switch on the warnings GCC warns you about few
possible similar errors, suggesting to add parentheses to remove some
ambiguity. A small example in C:

#include stdio.h
#include stdlib.h
int main() {
int a = atoi(10);
int b = atoi(20);
int c = atoi(30);
printf(%u\n, a|b = c);
return 0;
}

If you compile it with GCC 4.4.1:

gcc -Wall test.c -o test
test.c: In function 'main':
test.c:9: warning: suggest parentheses around comparison in operand of '|'

You always use -Wall (and other warnings) when you write C code, so here gcc is
able to catch such bugs.

This class of warnings can be added to the D compiler too.

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


[Issue 3834] forward reference in templated class

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3834



--- Comment #1 from bearophile_h...@eml.cc 2010-04-10 16:14:55 PDT ---
A simpler case example:

struct Foo(T) {
Node!T head;
struct Node(T) {}
}
void main() {
Foo!int f;
}


dmd 2.043 prints many errors:

test.d(2): Error: template instance Node!(int) forward references template
declaration Node(T)

test.d(2): Error: Node!(int) is used as a type
test.d(2): Error: variable test.Foo!(int).Foo.head voids have no value
test.d(6): Error: template instance test.Foo!(int) error instantiating

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


[Issue 3835] ref foreach does not work in CTFE

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3835



--- Comment #9 from bearophile_h...@eml.cc 2010-04-10 16:19:46 PDT ---
In dmd 2.043 my second tests cases works:

import std.stdio: writeln;

pure int[] genFactorials(int n) {
pure static int factorial(int n) {
if (n == 0)
   return 1;
return n * factorial(n - 1);
}

int[] result = new int[n + 1];
foreach (i; 0 .. n+1)
result[i] = factorial(i);
return result;
}

enum int N = 13;
static enum auto factorials = cast(int[N])genFactorials(N - 1);
void main() {
writeln(factorials);
}


The first test case doesn't work yet.

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


[Issue 3835] ref foreach does not work in CTFE

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3835



--- Comment #10 from bearophile_h...@eml.cc 2010-04-10 16:27:42 PDT ---
A reduced test case:

int foo() {
int[1] arr;
foreach (ref el; arr)
el = 10;
return arr[0];
}
enum int r = foo();
void main() {
assert(r == 10);
}

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


[Issue 4078] New: [CTFE] Failed return of dynamic array item

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4078

   Summary: [CTFE] Failed return of dynamic array item
   Product: D
   Version: future
  Platform: x86
OS/Version: Windows
Status: NEW
  Keywords: rejects-valid
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-10 16:41:23 PDT ---
int foo() {
int[] arr = new int[1];
return arr[0];
}
static assert(foo() == 0);
void main() {}


dmd 2.043 prints:

test1.d(5): Error: static assert  (null == 0) is not evaluatable at compile
time

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


[Issue 4079] New: [CTFE] Stack overflow from undetected circular reference

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4079

   Summary: [CTFE] Stack overflow from undetected circular
reference
   Product: D
   Version: future
  Platform: x86
OS/Version: Windows
Status: NEW
  Keywords: diagnostic
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-04-10 16:47:33 PDT ---
This is wrong D2 code:

int foo() {
assert(.r == 0);
return 0;
}
enum int r = foo();
void main() {}


dmd 2.043 shows a good enough error message (even if there's no need to print
the second error two times):

test.d(2): Error: circular reference to 'r'
test.d(5): Error: cannot evaluate foo() at compile time
test.d(5): Error: cannot evaluate foo() at compile time



This is another wrong D2 program:

int foo() {
return r;
}
enum int r = foo();
void main() {}


But this time dmd 2.043 shows:
Stack overflow

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


[Issue 4077] Bugs caused by bitwise operator precedence

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4077


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

   What|Removed |Added

 CC||bra...@puremagic.com


--- Comment #1 from Brad Roberts bra...@puremagic.com 2010-04-10 17:20:27 PDT 
---
Care to quantify 'frequent'?  Just because something can cause a bug doesn't
make it a disaster.  I can't recall ever making a bit wise precedence error
myself.  Of course, that too isn't proof of anything.

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


[Issue 4077] Bugs caused by bitwise operator precedence

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4077



--- Comment #2 from bearophile_h...@eml.cc 2010-04-10 19:54:25 PDT ---
Care to quantify 'frequent'?

I'd like to, but finding hard statical data about bugs is hard. Often you just
have to use your programming experience and memory of past mistakes. I have
programming experience, and for the last years I am writing down all my bugs.
You can ask the GCC developers what kind of statical data they have used to
decide to recently introduce that warning into gcc. I think they have no
reliable statistical data. But they are usually smart people, so you can't just
ignore their example.


Just because something can cause a bug doesn't make it a disaster.

Just because something can't cause disasters but just bugs doesn't justify
ignoring it. And sometimes silent bugs like this one actually cause disasters.


I can't recall ever making a bit wise precedence error myself. Of course, that 
too isn't proof of anything.

I have done several of similar bugs. Later I have taken the habit of always
putting parentheses around shift and bitwise ops, if they are compound with
other things.
That post on the D newsgroup shows Adam Ruppe too once has done this bug.


See the -Wparentheses here:
http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
It says several interesting things. It also says:

Warn if parentheses are omitted in certain contexts, such as when there is an 
assignment in a context where a truth value is expected, or when operators are 
nested whose precedence people often get confused about.

They say often get confused about.

That warning switch also warns against probably wrong code like (this is
another common source of bugs that's missing in Python):

if (a)
  if (b)
foo ();
else
  bar ();

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


[Issue 4077] Bugs caused by bitwise operator precedence

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4077


Adam D. Ruppe destructiona...@gmail.com changed:

   What|Removed |Added

 CC||destructiona...@gmail.com


--- Comment #3 from Adam D. Ruppe destructiona...@gmail.com 2010-04-10 
20:32:33 PDT ---
Yeah, when it bit me today, I wasn't thinking about it at all. The code looked
like this:

assert( a|b = max);

I meant (a|b) = max, but the code ended up being a|(b = max), which was
fairly useless.

I don't think bitwise being lower than comparison is useful, but we have the
difficulty here of maintaining C compatibility. The best fix we can get, if one
is really needed*, is to call it an error to have a bitwise operation next to
anything that trumps it, unless parenthesis are present.

The error brings instant attention to the trouble spot, and adding explicit
parens is no big trouble - I, and surely many others, usually do this by habit
anyway - so I'd be happy with this solution.

* (this is he only time I can recall being bitten by this in all my years of
writing C and friends, so it really isn't a big deal to me)

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


[Issue 4079] [CTFE] Stack overflow from undetected circular reference

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4079


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

   What|Removed |Added

   Keywords|diagnostic  |ice-on-invalid-code
 CC||clugd...@yahoo.com.au


--- Comment #1 from Don clugd...@yahoo.com.au 2010-04-10 21:40:38 PDT ---
This looks similar to bug 2315, but I suspect the cause may be quite different.

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


[Issue 4064] [CTFE] array.reverse doesn't work

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4064


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

   What|Removed |Added

 CC||clugd...@yahoo.com.au
   Severity|normal  |enhancement


--- Comment #1 from Don clugd...@yahoo.com.au 2010-04-10 21:52:53 PDT ---
Note that ANY call to the runtime cannot be be interpreted in CTFE (because
source code is not available). This bug, like bug 4021, is an enhancement
request.

The spec specifically says that .dup, .length, .keys, and .values are the only
built-in properties which are supported in CTFE. To support these others, they
would need to be (a) moved out of the runtime; or (b) special-cased in the
interpreter. And case (b) is not going to happen.


In 2.043, this gives the error message:

crash.d(38): Error: _adReverse cannot be interpreted at compile time, because
it
 has no available source code
crash.d(41): Error: cannot evaluate foo([1,2]) at compile time
crash.d(41): Error: cannot evaluate foo([1,2]) at compile time

which I think is slightly improved from before -- it at least explains that the
missing source code is the reason why it cannot work.

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