[Issue 6445] [CTFE] Absurd memory usage (still) on building array

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6445


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||INVALID


--- Comment #5 from Don clugd...@yahoo.com.au 2011-08-15 00:48:37 PDT ---
(In reply to comment #4)
 (In reply to comment #2)
  (In reply to comment #0)
   The following program uses over a gigabyte of memory at compile time.  I
   thought these kinds of issues were fixed by the rewrite of CTFE in the 
   last
   release.
  
  No, bug 1382 is still open. Some cases of it have been fixed (eg, the one in
  comment 4). I'm not sure why this particular case is so bad, I'll take a 
  look
  at it when I get a chance.
  Note that CTFE still uses copy-on-write for values, and no memory is ever
  released (this is more general than bug 1382). My guess is that the code 
  below
  just runs for a very long time.
 
 Values == ints, floats, other primitives?  What about static arrays?

Just integers (includes int, bool, char types) and floats. Static arrays aren't
duplicated.

This one just uses a lot of memory because it performs so many assignments, as
you can see if you count the number of iterations, as in the code below.
It's O(n^^2), so with n=1000, it loops about 4 million times.

It's nothing to do with arrays, and the memory usage is only linear with number
of assignments, so I'm marking this as invalid.
I'll create a new bug for the general memory usage issue.

---
enum staticFacTableLen = 10;
//  10 -- 436 iterations
// 100 --   45598 iterations
// 200 --  179242
// 400 --  704609
// 600 -- 1568674
// 800 -- out of memory

int makeLogFacTable() pure nothrow {

static int logCount(real x) pure nothrow @safe
{
immutable xMinusPlus = (x - 1) / (x + 1);
immutable xMinusPlusSquared = xMinusPlus * xMinusPlus;
real xMinusPlusPow = xMinusPlus * xMinusPlusSquared;
int kkk = 0;

real ret = xMinusPlus;
real power = 3;

while(true)
{
++kkk;
immutable toAdd = xMinusPlusPow / power;
immutable oldRet = ret;
ret += toAdd;

if(ret == oldRet || ret != ret)
{
return kkk;
}

power += 2;
xMinusPlusPow *= xMinusPlusSquared;
}

assert(0);
}
int totalcount = 0;
foreach(i; 1..staticFacTableLen) {
totalcount +=logCount(i);
}
return totalcount;
}

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


[Issue 6498] New: [CTFE] copy-on-write is slow and causes huge memory usage

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6498

   Summary: [CTFE] copy-on-write is slow and causes huge memory
usage
   Product: D
   Version: D1  D2
  Platform: Other
OS/Version: Windows
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: clugd...@yahoo.com.au


--- Comment #0 from Don clugd...@yahoo.com.au 2011-08-15 00:54:10 PDT ---
This is the main reason why CTFE is so slow.

int bug6498(int x)
{
int n = 0;
while (n  x)
++n;
return n;
}
static assert(bug6498(10_000_000)==10_000_000);

-- Fails with an 'out of memory' error.

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


[Issue 6491] Fully qualified values in default arguments of non-template functions are generated with an extra 'module' keyword

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6491


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-08-15 
01:09:20 PDT ---
https://github.com/D-Programming-Language/dmd/commit/9c23e891d9f58359aab67507261e26ee9340022e

https://github.com/D-Programming-Language/dmd/commit/4b4662fd7b81493dac5f178467a506c07309060e

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


[Issue 5667] [GSoC] clear does not call destructors on structs embedded in structs

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5667


Cristi Cobzarenco cristi.cobzare...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #10 from Cristi Cobzarenco cristi.cobzare...@gmail.com 2011-08-15 
09:26:53 PDT ---
The pull request was merged.

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


[Issue 6499] New: [GSoC] Destructor not called on object returned by method.

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6499

   Summary: [GSoC] Destructor not called on object returned by
method.
   Product: D
   Version: D2
  Platform: Other
OS/Version: Windows
Status: NEW
  Severity: blocker
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: cristi.cobzare...@gmail.com


--- Comment #0 from Cristi Cobzarenco cristi.cobzare...@gmail.com 2011-08-15 
09:56:42 PDT ---
Program:
import std.stdio;

struct Bar {
string m = not set;

this( string s ) { writeln( Constructor - , m = s ); }
this( this ) { writeln( Postblit- , m ); }
~this()  { writeln( Destructor  - , m ); }
Bar bar(){ return Bar( bar ); }
}

Bar foo() { return Bar( foo ); }

void main() {
foo().bar();
}

Output:
Constructor - foo
Constructor - bar
Destructor  - foo

The object returned by bar() is not destroyed (leading to a memory leak in my
GSoC project). Calling bar() directly, rather than on the result returned by
foo() works properly. Saving the result of bar() in a named variable doesn't
fix  the problem (it creates three objects and destroys only two).

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


[Issue 6489] Should be able to copy double[] to float[]

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6489


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

   What|Removed |Added

 CC||bugzi...@digitalmars.com
   Platform|Other   |All
 OS/Version|Windows |All
   Severity|normal  |enhancement


--- Comment #3 from Walter Bright bugzi...@digitalmars.com 2011-08-15 
11:50:21 PDT ---
What is the compelling rationale for this? Is there a use case that shows it?

(Also marked as an enhancement request, as it is not a bug.)

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


[Issue 2787] Members found in an 'alias this' are not implicitly accessible in methods

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2787


Kenji Hara k.hara...@gmail.com changed:

   What|Removed |Added

   Keywords||patch
 CC||k.hara...@gmail.com


--- Comment #2 from Kenji Hara k.hara...@gmail.com 2011-08-15 12:44:22 PDT ---
https://github.com/D-Programming-Language/dmd/pull/312

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


[Issue 6500] New: Show template instantiation values too

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6500

   Summary: Show template instantiation values too
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Keywords: diagnostic
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-08-15 14:30:20 PDT ---
This enhancement is of minor priority.

A small C++ program:


template int x
int foo(int y) {
unsigned int z = 10;
return y  z;
}
int main() {
foo5(6);
return 0;
}


On it G++ 4.6 shows a warning, and it shows x = 5 (the template instantiation
value) too:

...g++ -Wall test.cpp -o test
test.cpp: In function 'int foo(int) [with int x = 5]':
test.cpp:7:13:   instantiated from here
test.cpp:4:16: warning: comparison between signed and unsigned integer
expressions [-Wsign-compare]



I'd like DMD to do something similar, and show the template instatiation values
when it gives warnings:


int foo(int x)() {
return x;
static if (x  10)
return x + 1;
}
int main() {
return foo!(12)();
}


DMD 2.054 gives:
test.d(4): Warning: statement is not reachable


This enhancement request applies to warnings like the signed/unsigned one in
pull 119 too:
https://github.com/D-Programming-Language/dmd/pull/119

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


[Issue 6499] [GSoC] Destructor not called on object returned by method.

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6499


Kenji Hara k.hara...@gmail.com changed:

   What|Removed |Added

   Keywords||patch, wrong-code
 CC||k.hara...@gmail.com


--- Comment #1 from Kenji Hara k.hara...@gmail.com 2011-08-15 14:52:17 PDT ---
https://github.com/D-Programming-Language/dmd/pull/313

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


[Issue 596] Support array, arrayliteral and struct in switch and case

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=596



--- Comment #7 from bearophile_h...@eml.cc 2011-08-15 16:44:27 PDT ---
One more useful use is with OOP (this is GUI code):


import core.stdc.stdio;
class Control {}
class Slider : Control {}
class Button : Control {}
void main() {
Control c = new Button;
switch (typeof(c)) {
case Slider: printf(A); break;
case Button: printf(B); break;
default: // probably a Control
}
}



That is similar to this (but faster):

import core.stdc.stdio;
class Control {}
class Slider : Control {}
class Button : Control {}
void main() {
Control c = new Button;
 if (cast(Slider)c)  { printf(A); }
else if (cast(Button)c)  { printf(B); }
}

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


[Issue 6501] New: import inside of eponymous template does not work correctly

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6501

   Summary: import inside of eponymous template does not work
correctly
   Product: D
   Version: unspecified
  Platform: All
OS/Version: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: jmdavisp...@gmx.com


--- Comment #0 from Jonathan M Davis jmdavisp...@gmx.com 2011-08-15 20:35:34 
PDT ---
This code

template eponymous(string str)
{
import std.metastrings;

enum eponymous = Format!(%s, str);
}

void main()
{
pragma(msg, eponymous!(message));
}

incorrectly prints this during compilation:

eponymous!(message)

whereas if you move the import outside of the template, it correctly prints

message

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


[Issue 4099] Inconsistent behaviour of ++/-- when mixing opUnary and 'alias this'.

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4099


Kenji Hara k.hara...@gmail.com changed:

   What|Removed |Added

   Keywords||patch, rejects-valid
 CC||k.hara...@gmail.com


--- Comment #1 from Kenji Hara k.hara...@gmail.com 2011-08-15 20:38:36 PDT ---
https://github.com/D-Programming-Language/dmd/pull/314

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


[Issue 6502] New: failing with -release -inline -noboundscheck

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6502

   Summary: failing with -release -inline -noboundscheck
   Product: D
   Version: D2
  Platform: Other
OS/Version: All
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-08-15 
21:10:03 PDT ---
The following program fails when compiled with -release -inline -noboundscheck
-
import std.process;

void main()
{
}
---

with the message:

\cbx\mars\druntime\import\core\time.di(253): Error: template
core.time.TickDuration.to(string units,
T) if ((units == seconds || units == msecs || units == usecs || units ==
hnsecs || units ==
nsecs)  (__traits(isIntegral,T)  T.sizeof = 4)) does not match any
function template declarat
ion
\cbx\mars\druntime\import\core\time.di(253): Error: template
core.time.TickDuration.to(string units,
T) if ((units == seconds || units == msecs || units == usecs || units ==
hnsecs || units ==
nsecs)  (__traits(isIntegral,T)  T.sizeof = 4)) cannot deduce template
function from argument
 types !(seconds,long)() 

It is unclear if it is a druntime problem or a dmd bug.

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


[Issue 6502] failing with -release -inline -noboundscheck

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6502


Jonathan M Davis jmdavisp...@gmx.com changed:

   What|Removed |Added

 CC||jmdavisp...@gmx.com


--- Comment #1 from Jonathan M Davis jmdavisp...@gmx.com 2011-08-15 21:20:15 
PDT ---
There may very well be a druntime bug here, but I fail to see how something
compiling with one set of flags and failing to compile with another could be
anything other than a compiler bug (save for flags such as version which affect
conditional compilation).

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


[Issue 6463] Segfault on writeln() from a Fiber

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6463


d...@dawgfoto.de changed:

   What|Removed |Added

 CC||d...@dawgfoto.de


--- Comment #2 from d...@dawgfoto.de 2011-08-15 21:22:58 PDT ---
Can you please post the code.

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


[Issue 6434] opDispatch must be considered before alias this.

2011-08-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6434


Kenji Hara k.hara...@gmail.com changed:

   What|Removed |Added

   Keywords||patch, rejects-valid
 CC||k.hara...@gmail.com


--- Comment #1 from Kenji Hara k.hara...@gmail.com 2011-08-15 22:15:40 PDT ---
https://github.com/D-Programming-Language/dmd/pull/315

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