[Issue 8841] Missing line numbers in stack trace?

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8841


Brad Roberts  changed:

   What|Removed |Added

 CC||bra...@puremagic.com


--- Comment #1 from Brad Roberts  2012-10-17 22:37:47 PDT 
---
Did your build of any past version work correctly on your box?  If not, it's
not a regression.  If so, then please use git bisect to determine what commit
introduced the regression.

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


[Issue 2830] private attribute doesn't work for structs/unions/classes

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2830


Oleg Kuporosov  changed:

   What|Removed |Added

 CC||oleg.kuporo...@gmail.com


--- Comment #12 from Oleg Kuporosov  2012-10-17 
22:08:03 PDT ---
Peter's fixes from "Comment 11" is verified in dmd2.061 alpha, but looks wasn't
merged into D1 branch, so tests still failed in dmd1.076 alpha. This record wss
issued against D1 so status is unchanged.

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


[Issue 8831] core.atomic: add compare-and-swap function with other result type

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8831



--- Comment #7 from mimocrocodil <4deni...@gmail.com> 2012-10-17 20:45:45 PDT 
---
(In reply to comment #6)
> Please submit a pull request to:
> https://github.com/D-Programming-Language/druntime
> 
> Thanks!

Sorry, иге my clone of the druntime isn't builds now (with many warnings and
error, probably because old stable dmd compiler)

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


[Issue 8846] New: Inline Assembler: add support of cmpxchg16b opcode

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8846

   Summary: Inline Assembler: add support of cmpxchg16b opcode
   Product: D
   Version: D2
  Platform: x86_64
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: resume...@mail.ru


--- Comment #0 from Weed  2012-10-17 20:05:17 PDT ---
It can be useful for compare-and-swap of values (typically pointers), for cas2
(double cas) function implementation which can be used in lock-free code.

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


[Issue 8831] core.atomic: add compare-and-swap function with other result type

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8831


Alex R�nne Petersen  changed:

   What|Removed |Added

 CC||a...@lycus.org


--- Comment #6 from Alex R�nne Petersen  2012-10-18 05:00:07 
CEST ---
Please submit a pull request to:
https://github.com/D-Programming-Language/druntime

Thanks!

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


[Issue 8831] core.atomic: add compare-and-swap function with other result type

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8831


Weed  changed:

   What|Removed |Added

 CC||resume...@mail.ru


--- Comment #5 from Weed  2012-10-17 19:49:02 PDT ---
more intuitive test:

unittest // casw
{
shared size_t v = 2;
shared(size_t)* p = &v;
size_t compared;

auto r = casw( p, 3, 4, &compared );
assert( !r );
assert( v == 2 );
assert( compared == 2 );

compared = 0;

r = casw( p, 2, 4, &compared );
assert( r );
assert( v == 4 );
assert( compared == 2 );
}

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


[Issue 5854] Built-in array sort doesn't sort SysTime correctly

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5854


kekeni...@yahoo.co.jp changed:

   What|Removed |Added

 CC||kekeni...@yahoo.co.jp
  Component|DMD |Phobos


--- Comment #2 from kekeni...@yahoo.co.jp 2012-10-17 19:21:30 PDT ---
The cause is in Phobos library.(std.datetime)
Struct SysTime has some opCmp, but lacks the required one to overload.

http://dlang.org/arrays.html#array-properties
> For the .sort property to work on arrays of structs or unions, the struct or 
> union definition must define the function: int opCmp(ref const S) const. The 
> type S is the type of the struct or union. This function will determine the 
> sort ordering.

# I have no idea whether DMD could print an error or not.

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


Re: Regarding hex strings

2012-10-17 Thread bearophile

Jonathan M Davis:


You posted to the wrong list.

- Jonathan M Davis


Right Jonathan, I am sorry :-) I will try again in the main D 
newsgroup.


Bye,
bearophile


Re: Regarding hex strings

2012-10-17 Thread Jonathan M Davis
On Thursday, October 18, 2012 01:58:25 bearophile wrote:
[snip]

You posted to the wrong list.

- Jonathan M Davis


Regarding hex strings

2012-10-17 Thread bearophile
Maybe hex strings were invented in D1 when strings were 
convertible to char[]. But today strings are an array of 
immutable UFT-8, so I think this default type is now less useful:


void main() {
string data1 = x"A1 B2 C3 D4"; // OK
immutable(ubyte)[] data2 = x"A1 B2 C3 D4"; // error
}


Gives:
test.d(3): Error: cannot implicitly convert expression 
("\xa1\xb2\xc3\xd4") of type string to ubyte[]



Generally I'd like to use hex literals to put binary data nicely 
in a program, so usually I need an ubyte[] or uint[]. So I have 
to use something like:


auto data3 = cast(ubyte[])(x"A1 B2 C3 D4".dup);


So maybe the following literals are more useful in D2:

ubyte[]  data4a = x[A1 B2 C3 D4];
ubyte[4] data4b = x[A1 B2 C3 D4];
uint[]   data5a = x[A1 B2 C3 D4];
uint[2]  data5b = x[A1 B2 C3 D4];
ulong[]  data6a = x[A1 B2 C3 D4 A1 B2 C3 D4];
ulong[1] data6b = x[A1 B2 C3 D4 A1 B2 C3 D4];

Bye,
bearophile


[Issue 8838] Slicing static arrays should be considered unsafe (@system)

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8838



--- Comment #5 from Jonathan M Davis  2012-10-17 16:57:55 
PDT ---
> The code segment must be rejected, but what makes it unsafe is the escaping.
> Banning the slicing is not very precise.

It's exactly what happens with taking the address of a local variable. It's an
error if the compiler can determine that it's escaping, but it's @system
regardless. And because the compiler _can't_ guarantee that the reference isn't
escaping, it really has no choice but to make it @system to take the address or
slice in the first place. Doing otherwise would mean that it's possible to have
memory corruption issues when only using @safe code, which would be violating
@safe.

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


[Issue 8845] Can't pass immediate or rvalue args to ref function parameters

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8845


bearophile_h...@eml.cc changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc


--- Comment #1 from bearophile_h...@eml.cc 2012-10-17 16:50:18 PDT ---
(In reply to comment #0)

> This is particularly common when working with linear algebra. Vectors,
> matrices, quaternions are surely the most likely to produce this pattern.

Yes, it's a common pattern (Example: I have seen it often in a little
ray-tracer).

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


[Issue 8838] Slicing static arrays should be considered unsafe (@system)

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8838



--- Comment #4 from bearophile_h...@eml.cc 2012-10-17 16:47:12 PDT ---
(In reply to comment #3)

> The code segment must be rejected, but what makes it unsafe is the escaping.
> Banning the slicing is not very precise.

Region analysis is not one of the design goals of D, unfortunately. But a
little of such analysis will be useful in the D front-end.

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


[Issue 8838] Slicing static arrays should be considered unsafe (@system)

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8838


timon.g...@gmx.ch changed:

   What|Removed |Added

 CC||timon.g...@gmx.ch


--- Comment #3 from timon.g...@gmx.ch 2012-10-17 16:42:44 PDT ---
(In reply to comment #2)
> > This is a big change in D, so before going this route I suggest to think 
> > well
> about this topic.
> 
> The thing is that it _isn't_ memory safe. There's no question of that. So, per
> the definition of @safe, it has no business being @safe. It needs to be
> @system. If it's not, then SafeD is broken. I don't see how anyone could argue
> otherwise.
> ...

The code segment must be rejected, but what makes it unsafe is the escaping.
Banning the slicing is not very precise.

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


[Issue 8839] MmFile do not use Range

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8839



--- Comment #3 from Jonathan M Davis  2012-10-17 16:41:29 
PDT ---
> yes but it use opSlice method to do this not 
> - front back safe …

I don't know what you mean.

> In more why it is a class instead a struct ? MmFile do not use inheritance

It shouldn't be IMHO, but changing it would be a breaking change, so I wouldn't
expect it to be changed. I don't know why it was made a class in the first
place, but per the copyright, it looks like it came from D1 originally, and the
language could have changed quite a bit since MmFile was created, and it may be
that it made more sense at the time to make it a class, but I really don't
know.

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


[Issue 8838] Slicing static arrays should be considered unsafe (@system)

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8838



--- Comment #2 from Jonathan M Davis  2012-10-17 16:35:57 
PDT ---
> This is a big change in D, so before going this route I suggest to think well
about this topic.

The thing is that it _isn't_ memory safe. There's no question of that. So, per
the definition of @safe, it has no business being @safe. It needs to be
@system. If it's not, then SafeD is broken. I don't see how anyone could argue
otherwise.

Yes, it's breaking change in the cases where people actually use @safe, but
there's no way around that, and honestly, I suspect that most people don't mark
their code @safe anyway, and it's only applicable to where static arrays are
sliced, so I don't know how much code will really be broken. For folks who use
static arrays and @safe heavily, it'll break a lot. For most other people,
probably nothing.

Regardless, I don't see how we can _not_ make this change given what @safe is
supposed to do.

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


[Issue 8845] New: Can't pass immediate or rvalue args to ref function parameters

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8845

   Summary: Can't pass immediate or rvalue args to ref function
parameters
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: turkey...@gmail.com


--- Comment #0 from Manu  2012-10-17 16:31:24 PDT ---
Consider:
float length(ref const(Vector) x);

float distBetween = length(p1 - p0);
 or
float speed = length(player.getVelocity());

These don't work, forcing this horrible code:

Vector diff = p0 - p1;
float distBetween = length(diff);

Naturally, if I have a series of these operations, I end up with:

Vector diff0 = p0 - p1;
Vector diff1 = p1 - p2;
Vector diff2 = p2 - p0;

And it all starts getting very silly, the local namespace gets polluted very
quickly, and sensible temporary names often don't even exist for these
intermediate concepts, leading to really stupid names, or just random letters.

There's no difference in security. Forcing creation of a function scoped
variable just increases the probability of name conflict and inconveniences the
programmer. It would be nicer if the temporary was only scoped for life within
the functions call, and also un-named, so it doesn't pollute the functions
namespace.

I've heard arguments about the safety of the operation, but the 'workaround' is
just to create a temporary, which has identical security properties. It's also
no different than passing any pointer normally (a common suggestion), and no
reason to significantly inconvenience the programmer.

Perhaps this behaviour could be restricted to ref const, or ref in, if we're
getting worried about the safety of the operation? That would perhaps even
improve on how behaves now.

This is particularly common when working with linear algebra. Vectors,
matrices, quaternions are surely the most likely to produce this pattern.

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


[Issue 8839] MmFile do not use Range

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8839



--- Comment #2 from bioinfornatics  2012-10-17 
15:48:54 PDT ---
yes but it use opSlice method to do this not 
 - front back safe …
In more why it is a class instead a struct ? MmFile do not use inheritance

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


[Issue 8844] New: Warning for bug-prone operator overloading

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8844

   Summary: Warning for bug-prone operator overloading
   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 2012-10-17 15:46:15 PDT ---
struct Foo {
Foo opBinary(string op="-")(Foo f) {
return Foo();
}
}
void main() {
auto Foo = Foo() + Foo();
}


Compiles and run with no errors, dmd 2.061alpha, because "-" is a default
argument for the op template argument, so that code is formally correct. But
I'd like a warning here (or an error?), because I think such code is bug-prone.

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


[Issue 8843] New: Statically known slices given as fixed-size array arguments

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8843

   Summary: Statically known slices given as fixed-size array
arguments
   Product: D
   Version: D2
  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 2012-10-17 15:43:41 PDT ---
void foo(ref int[4] data) {}
void bar(in ref int[4] data) {}
void main() {
auto a = new int[10];
foo(a[0 .. 4]);
bar(a[0 .. 4]);
}



dmd 2.061alpha shows that currently that code is not accepted:

test.d(5): Error: function test.foo (ref int[4u] data) is not callable using
argument types (int[])
test.d(5): Error: cannot implicitly convert expression (a[0u..4u]) of type
int[] to int[4u]
test.d(6): Error: function test.bar (ref const(int[4u]) data) is not callable
using argument types (int[])
test.d(6): Error: cannot implicitly convert expression (a[0u..4u]) of type
int[] to const(int[4u])

But I think that code is worth accepting, when the slice width is known at
compile-time.

See also Issue 8838

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


[Issue 8842] New: Error line numbers for some run-time functions in debug mode?

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8842

   Summary: Error line numbers for some run-time functions in
debug mode?
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: druntime
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2012-10-17 15:35:01 PDT ---
void main() {
int[] foo;
auto bar = new int[10];
foo[] = bar[];
}


Currently that code gives a runtime error with no line number, dmd 2.061alpha:

object.Error: lengths don't match for array copy

The stack trace helps find the location of such error, but maybe in debug mode
(-debug) it's worth using a different _d_arraycopy run-time function that
accepts line numbers too (named _d_arraycopy_line or something), so it's able
to generate a more specific error message.

This line number inflates the binary, but in debug mode what's important is to
locate the errors very well.

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


[Issue 8839] MmFile do not use Range

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8839


Jonathan M Davis  changed:

   What|Removed |Added

 CC||jmdavisp...@gmx.com


--- Comment #1 from Jonathan M Davis  2012-10-17 15:26:14 
PDT ---
It works just fine with ranges. Just slice it to get an array over the mapped
memory. I've done it before, and it worked great. Essentially, MmFile is acting
like a container rather than a range and therefore provides range access to
what it contains rather than being a range itself.

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


[Issue 8841] New: Missing line numbers in stack trace?

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8841

   Summary: Missing line numbers in stack trace?
   Product: D
   Version: D2
  Platform: x86
OS/Version: Windows
Status: NEW
  Severity: regression
  Priority: P2
 Component: druntime
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2012-10-17 15:28:33 PDT ---
void main() {
int[] foo;
auto bar = new int[10];
foo[] = bar[];
}


I don't know if my self-compiled alpha-dmd is broken, or if I am just doing
something wrong, but I am not seeing line numbers nor Dmain:

DMD 2.061alpha:

...>dmd -g test.d
...>test
object.Error: lengths don't match for array copy

0x0040C068 in char[][] core.sys.windows.stacktrace.StackTrace.trace()
0x0040BEF3 in core.sys.windows.stacktrace.StackTrace
core.sys.windows.stacktrace.StackTrace.__ctor()
0x004025E8 in _d_arraycopy
0x00402554 in extern (C) int rt.dmain2.main(int, char**).void runMain()
0x0040258E in extern (C) int rt.dmain2.main(int, char**).void runAll()
0x004021A2 in main
0x00413A81 in mainCRTStartup
0x76FFD309 in BaseThreadInitThunk
0x77411603 in RtlInitializeExceptionChain
0x774115D6 in RtlInitializeExceptionChain


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


[Issue 8838] Slicing static arrays should be considered unsafe (@system)

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8838


bearophile_h...@eml.cc changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc


--- Comment #1 from bearophile_h...@eml.cc 2012-10-17 15:23:41 PDT ---
(In reply to comment #0)

> Taking the slice of a static array is really no different from taking the
> address of a local variable, and that's already @system, so slicing a static
> array should be as well.

This is a big change in D, so before going this route I suggest to think well
about this topic.

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


[Issue 8840] New: calculating minimum of longs with following comparison compiles to wrong code when enabling the optimizer

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8840

   Summary: calculating minimum of longs with following comparison
compiles to wrong code when enabling the optimizer
   Product: D
   Version: D2
  Platform: All
OS/Version: Windows
Status: NEW
  Keywords: wrong-code
  Severity: major
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: r.sagita...@gmx.de


--- Comment #0 from Rainer Schuetze  2012-10-17 14:16:55 
PDT ---
import core.stdc.stdio;

long foo() { return 4; }

void main()
{
long f1 = foo();
long f2 = foo();

long f = (f1 < f2 ? f1 : f2);
int len = (f == 0 ? 0 : printf("%llx\n", f));
}

compiled with "dmd -o" and running produces the output "40004" instead of
just "4".

Here's the disassembly:
_D4test3fooFZl  comdat
assume  CS:_D4test3fooFZl
mov EAX,4
xor EDX,EDX
ret
_D4test3fooFZl  ends
__Dmain comdat
assume  CS:__Dmain
L0: sub ESP,0Ch
pushEBX
pushESI
callnear ptr _D4test3fooFZl
mov 8[ESP],EAX
mov 0Ch[ESP],EDX
callnear ptr _D4test3fooFZl
cmp EDX,0Ch[ESP]
jl  L33
jg  L25
cmp EAX,8[ESP]
jbe L33
L25:mov ECX,0Ch[ESP]
mov EBX,8[ESP]
mov ESI,ECX
or  ESI,EBX
jmp short   L39
L33:mov ECX,EDX
mov EBX,EAX
or  ECX,EBX
L39:je  L4B
mov EAX,offset FLAT:_DATA
pushECX
pushEBX
pushEAX
callnear ptr _printf
add ESP,0Ch
L4B:xor EAX,EAX
pop ESI
pop EBX
add ESP,0Ch
ret
__Dmain ends

Note that ECX is pushed in the call to printf, but it is the result of
hiword|loword in the part after L33.

dmc suffers from the same problem.

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


[Issue 8839] New: MmFile do not use Range

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8839

   Summary: MmFile do not use Range
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bioinfornat...@gmail.com


--- Comment #0 from bioinfornatics  2012-10-17 
13:51:31 PDT ---
Dear,
In first i explain why this module is important to me:

i would like use mmfile as in bioinformatic file are really huge and this
technology should be faster than classical way

But they are two problems:
- any example , documentation or whatever …
- MmFile do not use Range

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


[Issue 8838] New: Slicing static arrays should be considered unsafe (@system)

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8838

   Summary: Slicing static arrays should be considered unsafe
(@system)
   Product: D
   Version: unspecified
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: jmdavisp...@gmx.com


--- Comment #0 from Jonathan M Davis  2012-10-17 13:45:53 
PDT ---
This code compiles just fine

int[] foo() @safe
{
int[5] a;
return a[];
}

void main()
{}

It really shouldn't. What it's doing is _not_ memory safe. And while
implementing issue# 7087 would fix this particular case, it doesn't fix the
problem in general, because all it takes is adding another function to the mix,
and the compiler can't catch it:

int[] foo() @safe
{
int[5] a;
return bar(a);
}

int[] bar(int[] a) @safe
{
return a;
}

void main()
{}

Taking the slice of a static array is really no different from taking the
address of a local variable, and that's already @system, so slicing a static
array should be as well.

Honestly, I wish that static arrays didn't implicitly slice when being passed
to functions taking dynamic arrays precisely because of how dangerous it is,
and the fact that the implicit conversion makes it really easy to miss, but at
least if it were marked @system, then it couldn't happen in @safe code, and it
would be harder to have bugs like in the code above.

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


[Issue 8837] New: BigInt/boolean error message

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8837

   Summary: BigInt/boolean error message
   Product: D
   Version: D2
  Platform: x86
OS/Version: Windows
Status: NEW
  Keywords: diagnostic
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2012-10-17 13:39:56 PDT ---
import std.bigint: BigInt;
void main() {
auto r1 = BigInt(10) / true;
auto r2 = BigInt(10) /= true;
}


DMD 2.061alpha gives:

...\dmd2\src\phobos\std\bigint.d(135): Error: operation not allowed on bool 'y'
...\dmd2\src\phobos\std\bigint.d(258): Error: template instance
std.bigint.BigInt.opOpAssign!("/",bool) error instantiating
test.d(3):instantiated from here: opBinary!("/",bool)
test.d(3): Error: template instance std.bigint.BigInt.opBinary!("/",bool) error
instantiating


If this operation is not allowed, then maybe it's better to disallow it
statically (maybe with a template constraint), to give a nicer/more clean error
message.

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


[Issue 8831] core.atomic: add compare-and-swap function with other result type

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8831



--- Comment #4 from mimocrocodil <4deni...@gmail.com> 2012-10-17 13:08:25 PDT 
---
bool casw( shared (size_t)* here, size_t ifThis, size_t writeThis, size_t*
comparedWith ) nothrow
{
static if( size_t.sizeof == long.sizeof )
{
asm
{
mov RDX, writeThis;
mov RAX, ifThis;
mov RCX, here;
mov RBX, comparedWith;
lock; // lock always needed to make this op atomic
cmpxchg [RCX], RDX;
mov [RBX], RAX;
setz AL;
}
}
else
static assert(false, "Unsupported architecture");
}

unittest
{
import std.stdio;
shared(size_t) o = 3;
shared(size_t) n = 4;
shared(size_t)* a = &n;

size_t compared;

auto r = casw( a, o, n, &compared );
assert( !r );
assert( compared == 4 );

a = &o;
r = casw( a, o, n, &compared );

assert( r );
assert( compared == 3 );
}

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


[Issue 8586] [ICE] (module.c, line 829) with -noboundscheck and local import

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8586


kekeni...@yahoo.co.jp changed:

   What|Removed |Added

 CC||andrej.mitrov...@gmail.com


--- Comment #3 from kekeni...@yahoo.co.jp 2012-10-17 11:10:49 PDT ---
*** Issue 7284 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 7284] ICE(module.c): with -inline -release -noboundscheck

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7284


kekeni...@yahoo.co.jp changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||kekeni...@yahoo.co.jp
 Resolution||DUPLICATE


--- Comment #2 from kekeni...@yahoo.co.jp 2012-10-17 11:10:49 PDT ---
These are independent of Issue 7305.

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

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


[Issue 8835] dmd: module.c:829: void Module::semantic3(): Assertion `semanticstarted == 2' failed.

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8835


kekeni...@yahoo.co.jp changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||kekeni...@yahoo.co.jp
 Resolution||DUPLICATE


--- Comment #1 from kekeni...@yahoo.co.jp 2012-10-17 11:07:57 PDT ---
*** This issue has been marked as a duplicate of issue 8586 ***

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


[Issue 8586] [ICE] (module.c, line 829) with -noboundscheck and local import

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8586


kekeni...@yahoo.co.jp changed:

   What|Removed |Added

 CC||jens.k.muel...@gmx.de


--- Comment #2 from kekeni...@yahoo.co.jp 2012-10-17 11:07:57 PDT ---
*** Issue 8835 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 7305] Internal error: backend\gother.c 983

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7305


kekeni...@yahoo.co.jp changed:

   What|Removed |Added

 CC||kekeni...@yahoo.co.jp


--- Comment #2 from kekeni...@yahoo.co.jp 2012-10-17 10:19:02 PDT ---
(In reply to comment #1)
> Duplicate of http://d.puremagic.com/issues/show_bug.cgi?id=7284 ?

It is independent.

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


[Issue 8803] map.filter.array run map delegate an incorrect number of time.

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8803


Andrei Alexandrescu  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||and...@metalanguage.com
 Resolution||WONTFIX


--- Comment #11 from Andrei Alexandrescu  2012-10-17 
09:26:02 PDT ---
There are clear advantages and disadvantages of both approaches, and reasonable
people may disagree on the choice. I will close this; formerly map did cache
its current element, to puzzlement by its users. I changed the behavior a long
time ago, to much less puzzlement.

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


[Issue 8803] map.filter.array run map delegate an incorrect number of time.

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8803



--- Comment #12 from deadalnix  2012-10-17 09:27:27 PDT ---
(In reply to comment #11)
> There are clear advantages and disadvantages of both approaches, and 
> reasonable
> people may disagree on the choice. I will close this; formerly map did cache
> its current element, to puzzlement by its users. I changed the behavior a long
> time ago, to much less puzzlement.

Then filter should call .front twice.

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


[Issue 8836] New: function called with argument types ((void function())) matches both f(void function() fn) and f(void delegate() dg)

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8836

   Summary: function called with argument types ((void
function())) matches both f(void function() fn) and
f(void delegate() dg)
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: luka8...@owave.net


--- Comment #0 from luka8088  2012-10-17 08:47:57 PDT ---
// http://dpaste.dzfl.pl/92347e75

import std.stdio;

void f (void function () fn) {}
void f (void delegate () dg) {}

void main () {
  f({ writeln("f"); });
}

-

Compilation output:

/home/c713/c345.d(8): Error: function c345.f called with argument types:
((void function()))
matches both:
/home/c713/c345.d(4): c345.f(void function() fn)
and:
/home/c713/c345.d(5): c345.f(void delegate() dg)

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


[Issue 8803] map.filter.array run map delegate an incorrect number of time.

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8803


William Moore  changed:

   What|Removed |Added

 CC||nyphb...@gmail.com


--- Comment #10 from William Moore  2012-10-17 06:33:27 PDT 
---
Changing the documentation to match does not necessarily make the code correct.
 In this case it means that the documentation is now broken as well.

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


[Issue 8835] New: dmd: module.c:829: void Module::semantic3(): Assertion `semanticstarted == 2' failed.

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8835

   Summary: dmd: module.c:829: void Module::semantic3(): Assertion
`semanticstarted == 2' failed.
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: major
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: jens.k.muel...@gmx.de


--- Comment #0 from jens.k.muel...@gmx.de 2012-10-17 06:31:13 PDT ---
The following code

import std.stdio;  

void main()
{
import std.file;
}

crashes with

dmd: module.c:829: void Module::semantic3(): Assertion `semanticstarted == 2'
failed.

when compiling with
-release -noboundscheck -inline

This is Linux.
$ dmd | head -1
DMD64 D Compiler v2.060

I'm sorry for not having a better test case.

As a work around. Moving import outside main fixes the problem. Alternatively,
you can avoid it by removing either -release, -noboundscheck, or -inline when
compiling.

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


[Issue 8803] map.filter.array run map delegate an incorrect number of time.

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8803



--- Comment #9 from deadalnix  2012-10-17 05:24:12 PDT ---
(In reply to comment #8)
> (In reply to comment #7)
> > Well, I do think many valid uses include impure functions, even in sort. For
> > instance for benchmarking purpose, for educational purpose, for caching.
> > 
> > More importantly, pure function isn't enough. A pure function can return 2
> > different objects. Even if the object's content will be the same, its 
> > identity
> > will not, which is a problem in many cases (the example above is 
> > simplified, in
> > my case that was the issue).
> 
> I think this issue boils down to this: you are expecting something from map,
> which is does not advertise to do (any more). There is no bug.
> 
> You could change this to an enhancement request, because you are asking for an
> additional feature.
> 

That wasn't an additional feature. Using such method, it is easy to solve the
entire bug database within the day.

The spec was made that way for good reason : this is how map works in every
single language that have map and allow side effects.

This violate the least principle and expose filter and map internals.

> Note that if you do add caching for 'front', you still have the same problem 
> if
> you try to use indexing. e.g.
> 
> auto xs = [1, 2, 3];
> auto m = xs.map!(fun)();
> auto ref a = m[1], b = m[1];
> 
> The only way this could guarantee to apply fun once is if it caches the entire
> range, which is totally impractical.

This can be solved by caching only 0 .. index . Or by caching within filter and
not map.

Or eventually by stating that this is not doable for indices. Most languages
don't allow index on map or create a temporary array automatically.

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


[Issue 8803] map.filter.array run map delegate an incorrect number of time.

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8803



--- Comment #8 from Peter Alexander  2012-10-17 
04:54:17 PDT ---
(In reply to comment #7)
> Well, I do think many valid uses include impure functions, even in sort. For
> instance for benchmarking purpose, for educational purpose, for caching.
> 
> More importantly, pure function isn't enough. A pure function can return 2
> different objects. Even if the object's content will be the same, its identity
> will not, which is a problem in many cases (the example above is simplified, 
> in
> my case that was the issue).

I think this issue boils down to this: you are expecting something from map,
which is does not advertise to do (any more). There is no bug.

You could change this to an enhancement request, because you are asking for an
additional feature.

Note that if you do add caching for 'front', you still have the same problem if
you try to use indexing. e.g.

auto xs = [1, 2, 3];
auto m = xs.map!(fun)();
auto ref a = m[1], b = m[1];

The only way this could guarantee to apply fun once is if it caches the entire
range, which is totally impractical.

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


[Issue 8803] map.filter.array run map delegate an incorrect number of time.

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8803



--- Comment #7 from deadalnix  2012-10-17 02:47:53 PDT ---
(In reply to comment #5)
> (In reply to comment #4)
> > The problem is that the delegate get executed an impredictable number of 
> > time.
> > Which make side effect extremely hard to handle (I ended up using
> > map.array.filter most of the time in my own codebase) in terms of 
> > side-effect
> > or performance.
> >
> > Additionally, the problem is dependent of the inner implementation of both 
> > map
> > and filter, which should stay unknown for the user.
> 
> I think the real problem here is that your mapping function has side effects.
> The undocumented intention of map is that the mapping function is pure. Using
> it to produce side-effects on the function call is not the intended use of map
> (just like having side effects in the comparison function in a sort would be a
> bad idea).
> 
> Other than the incorrect documentation, I don't think there is a bug here.

Well, I do think many valid uses include impure functions, even in sort. For
instance for benchmarking purpose, for educational purpose, for caching.

More importantly, pure function isn't enough. A pure function can return 2
different objects. Even if the object's content will be the same, its identity
will not, which is a problem in many cases (the example above is simplified, in
my case that was the issue).

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


[Issue 8824] std.container.Array fails to instantiate Array!char

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8824


monarchdo...@gmail.com changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 AssignedTo|nob...@puremagic.com|monarchdo...@gmail.com


--- Comment #1 from monarchdo...@gmail.com 2012-10-17 01:39:33 PDT ---
(In reply to comment #0)
> Trying to create an actual container (Array) of char elements fails.
> 
> This is because the allocated payload creates a char[], which is seen as a
> "string", as opposed to a "array of char".
> 
> The consequence is that it makes two calls choke:
> 1) Inside linearRemove: "copy" fails to operate on strings (good thing too).
> 2) Inside Payload.length: It calls initializeAll, which also fails on strings
> (arguably a good thing...?).
> 
> The work around is to simply use Array!dchar or Array!(u)byte.
> 
> While one could argue that Array!char *should* work, I do not think it is
> (currently) worth the effort.
> 
> Filling a bug report anyways.

Actually, I found a way to easily fix this.

Assigning to self.

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


[Issue 8818] CTFE fails to compare strings correctly

2012-10-17 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8818


Rainer Schuetze  changed:

   What|Removed |Added

   Keywords||patch


--- Comment #1 from Rainer Schuetze  2012-10-17 00:37:57 
PDT ---
https://github.com/D-Programming-Language/dmd/pull/1190

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