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

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2962


Andriy andr...@gmail.com changed:

   What|Removed |Added

 CC||andr...@gmail.com


--- Comment #33 from Andriy andr...@gmail.com 2011-05-23 02:35:44 PDT ---
dmd v2.052, Ubuntu, quite short example of this bug:

$ cat main.d 
import std.stdio;

void main(){}

$ cat utils.d
import std.json;

auto val = parseJSON!string;

$ dmd main.d utils.d 
/usr/include/d/dmd/phobos/std/conv.d(1301): Error: function
std.conv.parse!(real,string).parse compiler error, parameter 'p', bugzilla
2962?
dmd: glue.c:734: virtual void FuncDeclaration::toObjFile(int): Assertion `0'
failed.
Aborted (core dumped)

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


[Issue 6046] New: Not true for Java about Function Hijacking.

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6046

   Summary: Not true for Java about Function Hijacking.
   Product: D
   Version: unspecified
  Platform: Other
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: websites
AssignedTo: nob...@puremagic.com
ReportedBy: on...@yahoo.com


--- Comment #0 from Matthew Ong on...@yahoo.com 2011-05-23 02:45:48 PDT ---
Hi Digitalmars/Walter Bright,


http://www.digitalmars.com/d/2.0/hijack.html

This talk covers function hijacking, where adding innocent and reasonable
declarations in a module can wreak arbitrary havoc on an application program in
C++(maybe true) and Java(not true).

Since I have not done C++ for a long while, I am not going to comment about
that. But Java I have to place this request for correction from DigitalMars.

javac(from sun) Compiler will complain if there is an ambiguous to link any
indentifier that has the same signature for contructor,
methods(static/overloaded/overriden)

Overload Sets
Java denys global functions. All functions/methods are within a single class.
Within the same class, the overloaded methods cannot have the same signature.

public class MyClass{

public int myVal(){
}

public String myVal(){ // compiler will complain here as error and NOT warning.
}
}

Both the method identifier and zero param list makes a identical signature.

Derived Class Member Function Hijacking
IDE like Netbeans and does flag:

@override
public void myMethodA(){ // Say you did not use the override tag
}



Base Class Member Function Hijacking
to prevent the child class from stealing your implementation for this single
method, do:

public final void myMethodA(){ // final == sealed in C#
}


That is shown clearly when you tries to import both this 2 classes within Java:
import java.util.Date;
import java.sql.Date;

public class MyTest{
public static void main(String[] args){
 Date now=new Date(); // thinking that you are using java.util.Date;
}
}


Again, as a senior Java Developer since java jdk 1.1 I agrees D as a good
replacement for C++ because of modern design and approaches.

Kindly correct that to avoid confusing the new Java to D developer.

There are also other run time intelligent build into JVM to avoid malicious
hacker attack on such thing using class proxy  stub.

-- 
Matthew Ong
email: on...@yahoo.com

-- 
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

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2962



--- Comment #34 from Don clugd...@yahoo.com.au 2011-05-23 04:20:16 PDT ---
(In reply to comment #33)
 dmd v2.052, Ubuntu, quite short example of this bug:

snip
No, that's a long example -- it imports from Phobos. Test cases for compiler
bugs which import from Phobos are not completely reduced.
The examples in comments 20 and 29 are minimal test cases.

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


[Issue 6047] New: Segfault when struct with three or more ulongs with a toString is passed to format with at least two substitution clauses.

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6047

   Summary: Segfault when struct with three or more ulongs with a
toString is passed to format with at least two
substitution clauses.
   Product: D
   Version: D2
  Platform: Other
OS/Version: Linux
Status: NEW
  Severity: major
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: blood.of.l...@gmail.com


--- Comment #0 from Bernard Helyer blood.of.l...@gmail.com 2011-05-23 
05:01:35 PDT ---
import std.string;

struct A { ulong a, b, c; string toString() { return ; } }

void main()
{
A a;
format(%s%s, a, );
}



There has to be at least 24 bytes (or so) of declarations, so at least three
ulongs. The toString has to be there. That second parameter to format has to be
there.

Somewhere, there is stack corruption happening. This is preventing SDC's 64 bit
build from working correctly (it crashes when it errors, as the Location struct
is passed to format, manifesting this when its size_t decls are 64 bits wide).

This could be from DMD or Phobos. I'm not sure.

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


[Issue 6047] Segfault when struct with three or more ulongs with a toString is passed to format with at least two substitution clauses.

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6047



--- Comment #1 from Bernard Helyer blood.of.l...@gmail.com 2011-05-23 
05:05:16 PDT ---
I didn't mention my specs. Linux (64 or 32 bit build and output), 2.053 (but
it's been there for months, _at least_, to my knowledge), Phenom II X4, Arch
Linux.

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


[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705



--- Comment #9 from bearophile_h...@eml.cc 2011-05-23 05:12:44 PDT ---
Another example, compared to using minPos():


import std.stdio, std.algorithm, std.array;

void main() {
string[] data = [red, hello, yes, no, roger, bud];

// works in DMD 2.053
string r1 = minPos!q{ walkLength(a)  walkLength(b) }(data).front();
writeln(r1);

// proposed
string r2 = max!q{ walkLength(a) }(items);
writeln(r2);
}


The second version is shorter and more readable, and just like schwartzSort()
the modified max() is more efficient than using minPos when the mapping
function becomes costly to compute.

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


[Issue 6047] Segfault when struct with three or more ulongs with a toString is passed to format with at least two substitution clauses.

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6047



--- Comment #3 from Bernard Helyer blood.of.l...@gmail.com 2011-05-23 
06:31:32 PDT ---
I was mistaken -- it's only when building a 64 bit binary.

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


[Issue 6048] New: struct methods included in .tupleof

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6048

   Summary: struct methods included in .tupleof
   Product: D
   Version: D2
  Platform: Other
OS/Version: Mac OS X
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: rob...@octarineparrot.com


--- Comment #0 from Robert Clipsham rob...@octarineparrot.com 2011-05-23 
22:17:13 BST ---
The following code:

template canPersist(T) 
{
enum canPersist = canPersist!(T, typeof(T.tupleof));
}

template canPersist(T, U...) 
{
enum canPersist = canPersist!(T, U[0])  canPersist!(T, U[1..$]);
}

template canPersist(T, U : U*)
{
static assert(0, is this a bug in dmd? methods shouldn't be in .tupleof);
}

void main()
{
struct Test
{
bool opEquals(ref const Test other) const
{
return true;
}
}
enum foo = canPersist!Test;
}

Fails to compile with:

prog.d(13): Error: static assert  is this a bug in dmd? methods shouldn't be
in .tupleof
prog.d(3):instantiated from here: canPersist!(Test,void*)
prog.d(25):instantiated from here: canPersist!(Test)


Adding additional methods to Test has no effect (they don't show up in
.tupleof), same goes for normal fields (providing you add template
canPersist(T, U) { enum canPersist = true; }). Iterating over
typeof(Test.tupleof) in main() does not give the void* type.

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


[Issue 6048] struct methods included in .tupleof

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6048


kenn...@gmail.com changed:

   What|Removed |Added

 CC||kenn...@gmail.com


--- Comment #1 from kenn...@gmail.com 2011-05-23 15:25:24 PDT ---
This is expected. An inner struct contains a context pointer to the scope. Use
'static struct' and that 'void*' member will be gone. To illustrate:

---
void main() {
struct S{ void a(){} }
static struct T{ void b(){} }
pragma(msg, S.tupleof);
pragma(msg, T.tupleof);
}
---
tuple((S).this)
tuple()
---

(Although changing that struct to 'static struct' causes a forward-reference
error)

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


[Issue 1001] print stack trace (in debug mode) when program die

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1001



--- Comment #40 from Sean Kelly s...@invisibleduck.org 2011-05-23 15:27:35 
PDT ---
The code for this is in core/runtime.  If you're using a custom dmd.conf, the
problem may be that you're missing an -L--export-dynamic.

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


[Issue 1001] print stack trace (in debug mode) when program die

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1001



--- Comment #41 from Matt Peterson revcompg...@gmail.com 2011-05-23 15:41:50 
PDT ---
(In reply to comment #40)
 The code for this is in core/runtime.  If you're using a custom dmd.conf, the
 problem may be that you're missing an -L--export-dynamic.

I'm not using a custom dmd.conf and that switch is there.

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


[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705



--- Comment #10 from bearophile_h...@eml.cc 2011-05-23 16:12:53 PDT ---
The code that uses minPos() also leads to a possible bug (a real bug I have
found in my code), shown here:


import std.stdio, std.algorithm, std.math, std.range, std.random;
int gen(int x) { return uniform(-100, 100); }
void main() {
auto data = map!gen(iota(10));
writeln(data);
writeln(data);
int result = minPos!((a, b){ return abs(a)  abs(b); })(data).front();
writeln(result);
}


The output shows that gen is recomputed every time data is used, so
abs(a)abs(b) gives bogus results:
[-87, -1, 86, -93, -89, 16, 17, -91, 55, 88]
[-36, 91, 38, 6, 23, 85, 60, -25, -48, -100]
-97

(Maybe I'd like an annotation to tell the compiler that data is an an Input
Range, unlike iota() that map is iterating on.)


To avoid that bug you have to turn data into an array:

import std.stdio, std.algorithm, std.math, std.range, std.random;
int gen(int x) { return uniform(-100, 100); }
void main() {
auto data = array(map!gen(iota(10)));
writeln(data);
writeln(data);
int result = minPos!((a, b){ return abs(a)  abs(b); })(data).front();
writeln(result);
}


Now abs(a)abs(b) gets computed on something that's not changing under the
carpet, and there is no bug:
[-41, -36, -15, -35, 91, 31, -5, -67, -91, -65]
[-41, -36, -15, -35, 91, 31, -5, -67, -91, -65]
-5



In code like this there is no need to turn data into an array, the result is
correct even keeping data lazy because items of data are accessed only once
to compute abs(a):


import std.stdio, std.algorithm, std.math, std.range, std.random;
int gen(int x) { return uniform(-100, 100); }
void main() {
auto data = map!gen(iota(10));
int result = min!q{ abs(a) }(data);
writeln(result);
}

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


[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4705



--- Comment #11 from bearophile_h...@eml.cc 2011-05-23 16:16:25 PDT ---
(In reply to comment #10)

 (Maybe I'd like an annotation to tell the compiler that data is an an Input
 Range, unlike iota() that map is iterating on.)

This bug doesn't happen if the mapping function of map() is pure.

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


[Issue 1001] print stack trace (in debug mode) when program die

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1001



--- Comment #42 from Jonathan M Davis jmdavisp...@gmx.com 2011-05-23 17:44:47 
PDT ---
I haven't been seeing the stack traces with 64-bit either. I don't even get the
addresses (which is what you get if you don't have -L--export-dynamic). I'm
seeing the same behavior as Matt. It works fine on my 32-bit machine, but on my
64-bit machine where I'm using pure 64-bit D (dmd, druntime, and Phobos are all
64-bit), the stack traces are always empty.

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


[Issue 1001] print stack trace (in debug mode) when program die

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1001



--- Comment #43 from Matt Peterson revcompg...@gmail.com 2011-05-23 21:05:38 
PDT ---
I just tested building with -m32 and that works, although the symbols are
still mangled. With -m64 I don't get any lines in the stack trace at all. In
fact, I only see one line of -. I'm not not getting the one there
should be at the end.

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


[Issue 6049] [CTFE]: Array literals of structs with invariant() are wrong

2011-05-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6049


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

   What|Removed |Added

 CC||jmdavisp...@gmx.com


--- Comment #1 from Jonathan M Davis jmdavisp...@gmx.com 2011-05-23 21:35:53 
PDT ---
So, as a temporary fix to make the autotester is passing, commenting out the
invariants should fix the problem?

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