[Issue 2783] New: Truncation of long string by std.stdio.write

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2783

   Summary: Truncation of long string by std.stdio.write
   Product: D
   Version: 2.026
  Platform: PC
   URL: http://www.britseyeview.com/middle.txt
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: bugzi...@digitalmars.com
ReportedBy: steve.te...@britseyeview.com


Walter,

The file middle.txt at the URL above has lines numbered up to 555. If I read it
into a string and std.stdio.write the string to the console, the output is
truncated at line 261.

import std.file;
import std.stdio;
import std.c.stdio;

void main()
{
   string s2 = cast(immutable(char[])) std.file.read(middle.txt);
   std.stdio.write(s2);
   printf(%s, (s2 ~ \x00).ptr);
}

It isn't std.file.read, as I got similar behavior when the string was output to
the console from the program that generated middle.txt - then it was at line
221.

I checked the string for embedded zeroes and 0x1a when it was doing the fail at
221, but it seemed to be OK.

printf works as expected.

I'm sorry I can't come up with anything more compact than this, and I'm
probably missing something stupid.

Steve


-- 



[Issue 2625] Creating new struct with literal bypasses immutability of members if struct is in array

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2625


ma...@pochta.ru changed:

   What|Removed |Added

OtherBugsDependingO||2573
  nThis||




--- Comment #2 from ma...@pochta.ru  2009-04-02 07:02 ---
According to specs http://digitalmars.com/d/2.0/struct.html works() is correct.
I think, broken() is correct, since invariant data can be referenced directly,
so it's incorrect for it to change in time.


-- 



[Issue 2783] Truncation of long string by std.stdio.write

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2783





--- Comment #2 from ma...@pochta.ru  2009-04-02 07:40 ---
format.d
1623: short precision = short.max - 1;
2010: auto s = obj[0 .. f.precision  $ ? f.precision : $];
2016: w.write(s);

try std.stdio.write(%s,s2);


-- 



[Issue 2757] resource management in a timely manner

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2757


ma...@pochta.ru changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||INVALID




--- Comment #2 from ma...@pochta.ru  2009-04-02 07:50 ---
This guy wants gc to free unmanaged resources each 10 seconds, because if gc
objects, wrapping those resources, don't occupy much space, gc won't bother to
collect garbage.


-- 



[Issue 2783] Truncation of long string by std.stdio.write

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2783





--- Comment #3 from and...@metalanguage.com  2009-04-02 08:23 ---
I've fixed the problem, will be part of the next release.

Andrei


-- 



[Issue 918] Template order matter, version block change something with typedef, and another template bug.

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=918


bary...@smp.if.uj.edu.pl changed:

   What|Removed |Added

Version|1.004   |1.039




--- Comment #2 from bary...@smp.if.uj.edu.pl  2009-04-02 08:38 ---
Just tested in newer compiler, same behaviour. (1.004, and 1.039)


-- 



[Issue 808] using properties as lvalues

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=808





--- Comment #1 from bary...@smp.if.uj.edu.pl  2009-04-02 08:49 ---
Assigment to properties is actually call to some method which actually do other
operations (like reallocation). I think that
   p op= x,
properties operations should be defined as
  p = p op x

Also for user defined properties (if both setter and getter is availble, so
lvalue-like behaviour can be emulated in this way). Cases in which p += x,
should be performed differently can always be emulated by using wrapper
struct/class, which caries state and overloads opAddAssign. This cases are
rear, but still possible. (usefull for some highly optimized codes, or
synchronized/atomic changes, or loging actuall changes)



array.length *= 2;  is one of the most annoying :)


-- 



[Issue 1897] dmd SEGV with template function

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1897





--- Comment #1 from clugd...@yahoo.com.au  2009-04-02 10:35 ---
Works for me, Windows DMD 2.027.


-- 



[Issue 2199] Segfault using array operation in function call

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2199


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

   What|Removed |Added

   Keywords||patch




--- Comment #3 from clugd...@yahoo.com.au  2009-04-02 10:47 ---
Problem is in elem *AddExp::toElem(IRState *irs)
e2ir.c, line 1925 -- returns an uninitialized variable e.


error(Array operation %s not implemented, toChars());
return e1-toElem(irs); // prevent segfault


-- 



[Issue 2784] New: Interfaces should be able to require type definitions

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2784

   Summary: Interfaces should be able to require type definitions
   Product: D
   Version: unspecified
  Platform: PC
OS/Version: Linux
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: bugzi...@digitalmars.com
ReportedBy: and...@metalanguage.com


This should work:

interface Foo
{
typedef Bar;
}

meaning that the interface should contain a type Bar, without any additional
restriction on Bar.


-- 



[Issue 2786] New: Interfaces should be able to require constructors

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2786

   Summary: Interfaces should be able to require constructors
   Product: D
   Version: unspecified
  Platform: PC
OS/Version: Linux
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: bugzi...@digitalmars.com
ReportedBy: and...@metalanguage.com


This should work:

interface Foo
{
this(); // default construction is enabled
this(this); // copy construction is enabled
this(int); // construction from an int
}

Copy construction does not make sense for classes, but will make for struct
once struct inheritance of interfaces will be defined.


-- 



[Issue 2785] Interfaces should be able to require non-member functions

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2785





--- Comment #1 from jarrett.billings...@gmail.com  2009-04-02 13:18 ---
I agree with the suggestion, but why not 'static'?


-- 



[Issue 2215] Forward reference enum with base type within a struct causes Segmentation Fault in the compiler

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2215





--- Comment #2 from clugd...@yahoo.com.au  2009-04-02 14:52 ---
This is segfaulting in mtype.c, line 5156. If the enum is forward referenced,
it doesn't know if it's default-initialised, so defaultval is null - segfault. 

int TypeEnum::isZeroInit()
{
return sym-defaultval-isBool(FALSE);
}

Unfortunately, 'loc' is not a parameter to isZeroInit, so I don't know how to
give an error msg with missing line number.
There are actually two other places in TypeEnum where this problems happens:
isunsigned() uses memtype without checking.
hasPointers() uses toBaseType() without checking.

alignsize() probably gives error message without line number.


-- 



[Issue 2555] ICE using invalid tuple property in a declaration

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2555


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

   What|Removed |Added

Summary|Segfault using invalid tuple|ICE using invalid tuple
   |property in a declaration   |property in a declaration




--- Comment #1 from clugd...@yahoo.com.au  2009-04-02 14:59 ---
No longer segfaults. Gives correct error messages on DMD2.027, while on
DMD1.042 it ICEs:

Assertion failure: 'i  parameters-dim' on line 806 in file 'template.c'


-- 



[Issue 1927] dmd SEGV when passing invalid symbol as parameter

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1927





--- Comment #1 from clugd...@yahoo.com.au  2009-04-02 15:07 ---
Like 1897, this works for me on Windows, DMD 1.042 and 2.027. Probably fixed.


-- 



[Issue 2577] DMD crashes on foreach of undefined identifier

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2577


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

   What|Removed |Added

   Keywords||patch




--- Comment #3 from clugd...@yahoo.com.au  2009-04-02 15:42 ---

in expression.c, in CallExp::canThrow(), around line 6660, type will be null if
the expression was invalid. Adding a null check fixes the segfault.

/* If calling a function or delegate that is typed as nothrow,
 * then this expression cannot throw.
 * Note that pure functions can throw.
 */
if (!e1-type) return 0;  //  add this line

Type *t = e1-type-toBasetype();
if (t-ty == Tfunction  ((TypeFunction *)t)-isnothrow)
return 0;


-- 



[Issue 2788] New: return val not passable via ref const in other method

2009-04-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2788

   Summary: return val not passable via ref const in other method
   Product: D
   Version: 2.027
  Platform: PC
OS/Version: Windows
Status: NEW
  Keywords: rejects-valid
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: bugzi...@digitalmars.com
ReportedBy: s...@extrawurst.org


This used work perfectly fine, why not anymore ? (since 2.027)

[CODE]
int getVar()
{
return 2;
}

void foo(ref const int _p)
{}

void main()
{
foo(getVar());
}
[/CODE]

Error: function main.foo (ref const const(int) _p) does not match parameter
types (int)
Error: getVar() is not an lvalue


-- 



Re: [Issue 2580] Documented WinMain for D2 is wrong

2009-04-02 Thread Sean Kelly

d-bugm...@puremagic.com wrote:

http://d.puremagic.com/issues/show_bug.cgi?id=2580

--- Comment #6 from s...@iname.com  2009-04-01 20:18 ---
Sean, where are you at with this at the moment?


I forgot about this ticket until the release went out and I was looking 
through bugzilla for stuff to close.  It will be fixed in the next release.


Re: [Issue 2757] resource management in a timely manner

2009-04-02 Thread Sean Kelly

d-bugm...@puremagic.com wrote:


--- Comment #2 from ma...@pochta.ru  2009-04-02 07:50 ---
This guy wants gc to free unmanaged resources each 10 seconds, because if gc
objects, wrapping those resources, don't occupy much space, gc won't bother to
collect garbage.


The I suggest creating a thread that calls GC.collect() and then sleeps 
for ten seconds in a loop.


Re: [Issue 2757] resource management in a timely manner

2009-04-02 Thread dsimcha
== Quote from Sean Kelly (s...@invisibleduck.org)'s article
 d-bugm...@puremagic.com wrote:
 
  --- Comment #2 from ma...@pochta.ru  2009-04-02 07:50 ---
  This guy wants gc to free unmanaged resources each 10 seconds, because if 
  gc
  objects, wrapping those resources, don't occupy much space, gc won't bother 
  to
  collect garbage.
 The I suggest creating a thread that calls GC.collect() and then sleeps
 for ten seconds in a loop.

Come to think of it, as simple and kludgey sounding as it is, this is an
incredibly good idea if you have an app that does a lot of sitting around 
waiting
for input, etc. and therefore not allocating memory and you want an easy way to
make sure it releases resources in a reasonable amount of time.  This belongs in
an FAQ somewhere.