[Issue 7375] New: Regression(2.057): Invalid downcast permitted with derived/aliased template classes

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7375

   Summary: Regression(2.057): Invalid downcast permitted with
derived/aliased template classes
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Keywords: wrong-code
  Severity: regression
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: cbkbbej...@mailinator.com


--- Comment #0 from Nick Sabalausky cbkbbej...@mailinator.com 2012-01-27 
00:22:38 PST ---
a.d:

import b;

void main(string[] args)
{
auto foo = getEleven();
//auto dummy = cast(Derived!11)foo;
assert(cast(Derived!22)foo is null);
}

alias DerivedAlias!22 X;


b.d:

module b;

Base getEleven()
{
Base foo = new MoreDerived!11(null);
return foo;
}

class Base
{
Base a;
this(Base a)
{
this.a = a;
}
}

class Derived(int i) : Base
{
this(Base a)
{
super(a);
}
}

class MoreDerived(int i) : Derived!i
{
this(Base a)
{
super(a);
}
}

template DerivedAlias(int i)
{
alias Derived!i DerivedAlias;
}


On 2.057, the assert fails. (It's fine on 2.056.)

If you uncomment the dummy line, the problem goes away (merely creating an
alias for Derived!11 does not work). However, that's *not* a general workaround
because in order to test what the runtime type is, you have to *already* know
*all* the types it might be and attempt to downcast to each of them.

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


[Issue 7375] Regression(2.057): Invalid downcast permitted with derived/aliased template classes

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7375



--- Comment #1 from Nick Sabalausky cbkbbej...@mailinator.com 2012-01-27 
00:26:47 PST ---
Sorry, I forgot to finish minimizing b.d. The properly minimized b.d is:


module b;

Base getEleven()
{
Base foo = new MoreDerived!11();
return foo;
}

class Base {}
class Derived(int i) : Base {}
class MoreDerived(int i) : Derived!i {}

template DerivedAlias(int i)
{
alias Derived!i DerivedAlias;
}


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


[Issue 7376] New: floating point bug

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7376

   Summary: floating point bug
   Product: D
   Version: D2
  Platform: x86_64
OS/Version: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: iteronve...@gmail.com


--- Comment #0 from iteronve...@gmail.com 2012-01-27 00:29:06 PST ---
As discussed in this thread:
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.comgroup=digitalmars.D.learnartnum=31864

Shorter version of the bug:

import std.stdio;

void calculate1(float a, float b)
{
   float s1 = 1.0f - a;

   float s2 = a * b;
   writeln(s2);
   writeln(a * b);
}

void calculate2(float a, float b)
{
   float s1 = 1.0 - a;
   float s2 = a * b;
   writeln(s2);
   writeln(a * b);
}

void calculate3(double a, double b)
{
   double s1 = 1.0 - a;
   double s2 = a * b;
   writeln(s2);
   writeln(a * b);
}

int main()
{  
   writeln(calculate1:);
   calculate1(0.75f,2.0f);
   writeln(calculate2:);
   calculate2(0.75f,2.0f);
   writeln(calculate3:);
   calculate3(0.75f,2.0f);
   return 0;
}


-
+   The complete output
-

calculate1:
1.5
1.5
calculate2:
0
1.5
calculate3:
1.5
1.5

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


[Issue 4841] -inline wrecks nested struct with alias template parameter (An array()/map inlining problem)

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4841


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

   What|Removed |Added

   Target Milestone|--- |2.059
Summary|-inline wrecks delegate |-inline wrecks nested
   |literals as alias   |struct with alias template
   |parameters (An array()/map  |parameter (An array()/map
   |inlining problem)   |inlining problem)


--- Comment #4 from Don clugd...@yahoo.com.au 2012-01-27 00:35:53 PST ---
Further reduced shows neither constructor nor delegate is required.

struct Struct4841(alias pred)
{
void unused_func();
}

void bug4841a() {
   int w;
   Struct4841!(  w ) m;   
}

void bug4841b() {
   bug4841a();
}


The unused function is required only because it makes Struct4841 into a nested
struct.
I think it is because moving a templated nested struct changes its type - the
enclosing function is part of the mangled name, or something like that. It
can't trivially be moved around.

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


[Issue 7197] enum string doesn't work with CTFE

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7197



--- Comment #3 from github-bugzi...@puremagic.com 2012-01-27 00:51:34 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/6c081a2bf05524c83e87c71819a9240009a8a7e7
7197 enum string doesn't work with CTFE

Fixes bug 7197.
Oddly, this was actually a bug in the const folding for comma expressions.
The code was originally there as a workaround for another problem which has
since been fixed.

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


[Issue 7376] floating point bug

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7376


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

   What|Removed |Added

 CC||bugzi...@digitalmars.com


--- Comment #1 from Walter Bright bugzi...@digitalmars.com 2012-01-27 
01:40:06 PST ---
I tried this on Ubuntu Linux with the latest build:

dmd foo -O
dmd foo
dmd foo -O -inline

and could not reproduce an error. The generated code looks fine, too.

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


[Issue 7166] Internal error: ../ztc/cgxmm.c 60

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7166


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

   What|Removed |Added

 CC||bugzi...@digitalmars.com


--- Comment #1 from Walter Bright bugzi...@digitalmars.com 2012-01-27 
01:53:33 PST ---
Reduced example:

cdouble inv( cdouble expr )
{
return (1.0 + 0.0i) / expr;
}

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


[Issue 7376] floating point bug

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7376


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

   What|Removed |Added

 CC||jmdavisp...@gmx.com


--- Comment #2 from Jonathan M Davis jmdavisp...@gmx.com 2012-01-27 02:01:59 
PST ---
I see it on 2.057 without -inline or -O (the problem seems to go away with
either of those flags), but I don't see it at all on the latest from github.
This using using 64-bit Arch Linux.

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


[Issue 7197] enum string doesn't work with CTFE

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7197


Walter Bright bugzi...@digitalmars.com 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 7166] Internal error: ../ztc/cgxmm.c 60

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7166



--- Comment #2 from github-bugzi...@puremagic.com 2012-01-27 02:41:46 PST ---
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/2d9f3cb5489de4f99789681236eee5c989003851
fix Issue 7166 - Internal error: ../ztc/cgxmm.c 60

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


[Issue 7377] New: Compiler segfault in: TemplateMixin::hasPointers()

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7377

   Summary: Compiler segfault in: TemplateMixin::hasPointers()
   Product: D
   Version: future
  Platform: All
OS/Version: All
Status: NEW
  Severity: critical
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: dl...@chilon.net


--- Comment #0 from pelo dl...@chilon.net 2012-01-27 03:41:27 PST ---
Using the latest built dmd/phobos/druntime code from git I get a compiler core
dump:

Core was generated by `dmd -I../.. -g -debug -od../.obj -of../.obj/variant
common.d variant.d ../teg/s'.
Program terminated with signal 11, Segmentation fault.
#0  0x004f7a2f in TemplateMixin::hasPointers() ()
(gdb) bt
#0  0x004f7a2f in TemplateMixin::hasPointers() ()
#1  0x0050cc0e in ClassDeclaration::toObjFile(int) ()
#2  0x004a024f in Module::genobjfile(int) ()
#3  0x00403c4f in main ()

I'm trying to build a minimal test case. dmd 2.047 has other compilation
segfaults affecting my code, I'm a little worried I'll never be able to build
my code with any D compiler above 2.046 again ;)

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


[Issue 7372] Error provides too little information to diagnose the problem (error: undefined identifier)

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7372


Leandro Lucarella leandro.lucare...@sociomantic.com changed:

   What|Removed |Added

   Keywords|rejects-valid   |diagnostic
 Status|RESOLVED|REOPENED
 Resolution|INVALID |
Summary|(Regression git) wrong  |Error provides too little
   |error: undefined identifier |information to diagnose the
   ||problem (error: undefined
   ||identifier)
   Severity|regression  |normal


--- Comment #2 from Leandro Lucarella leandro.lucare...@sociomantic.com 
2012-01-27 04:00:32 PST ---
(In reply to comment #1)
 This is not a bug.
 
 From the spec: Unlike a template instantiation, a template mixin's body is
 evaluated within the scope where the mixin appears, not where the template
 declaration is defined.
 
 The default for imports is private, so m1.bug is not visible to m.C.

OK, so the case with the alias works because aliases are public by default,
right? Then using private alias m1.bug bug; I get this error:
m2.d(7): Error: module m m2.bug is private

Which describes the problem a little better. I will reopen this (lowering the
importance) to keep in mind the error message should be improved. The current
error gives no NO clue about the real location of the problem, which should be
the instantiation site, I think.

The private alias error is a little better in that regard but could be more
specific too. This is the main reason why this problem was SO hard to reduce to
a small test case. I was extremely hard to find out where the root problem was
because the error is triggered in the template, which in the real code is
instantiated from many places.

Besides that, I think this is a really nasty corner case then. So using a mixin
will require either:

1) Pollute the user's namespace by publicly importing everything the template
use
2) Asking the user to know the details of the mixin implementation and import
things according.

It there any other solution to this problem that doesn't have those 2 problems?
I guess doing the imports INSIDE the template would be an option, thus
polluting only the class name space and not the entire module, but there is
still pollution going on.

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


[Issue 648] DDoc: unable to document mixin statement

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=648


Marco Leise marco.le...@gmx.de changed:

   What|Removed |Added

 CC||marco.le...@gmx.de


--- Comment #5 from Marco Leise marco.le...@gmx.de 2012-01-27 05:12:41 PST ---
(In reply to comment #0)
 /// this is a class
 class A
 {
 /// This mixin will bla bla bla
 mixin MyMixin!();
 }
 
 this will only generate docs for the class. not the mixin.
 Some will probably consider this a feature request, but I'd call it a bug...

I would call it a feature request, because for it to be a bug, there would have
to be a clear definition how this should work or a similar case that can act as
a template. DDoc documents 'classes', 'structs', 'methods', ... in other words
named symbols. mixin MyMixin; isn't a symbol and usually not interesting for
the user of the class. And private members aren't documented, because they
aren't usable by the target audience of API docs. So I assume your mixin does
not itself add public symbols that should be documented ? Or do you request a
feature to go beyond API documentation with DDOC, and also document how a mixin
is expanded in the class ? That's what normal comments are for!

Maybe you can elaborate a bit on what the mixin does and why it is necessary to
document the 'unexpanded' thing ? I would say yes, if you proposed to move DDOC
generation after mixin expansion (so newly introduced methods can be
documented), but then you could document them inside the mixin itself - which
would be a different 'bug'. Remember that a single mixin can add any number of
new symbols, so documentation above mixin ... may come short in many
situations. You can also discuss this on the D newsgroup, but be sure to give a
strong argument (real example code) for this feature.

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


[Issue 7293] dmd 2.057 segfault/crash - std.regex.match(string, string)

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7293


Stewart Gordon s...@iname.com changed:

   What|Removed |Added

   Keywords||ice-on-valid-code
 CC||s...@iname.com
   Platform|x86_64  |All
Summary|dmd 2.057 segfault  |dmd 2.057 segfault/crash -
   ||std.regex.match(string,
   ||string)
 OS/Version|Linux   |All


--- Comment #2 from Stewart Gordon s...@iname.com 2012-01-27 05:26:43 PST ---
Please remember to:
- assign keywords as appropriate
- make summary lines specific to the bug
- change platform/OS to All if you witness it on something different from
what the reporter reported it on.

Even smaller testcase:
-
import std.regex;
auto m = match(, );
-

Crash report (DMD 2.057, Windows Vista 32-bit:
-
  Problem Event Name:APPCRASH
  Application Name:dmd.exe
  Application Version:0.0.0.0
  Application Timestamp:
  Fault Module Name:dmd.exe
  Fault Module Version:0.0.0.0
  Fault Module Timestamp:
  Exception Code:c005
  Exception Offset:0003c6b2
  OS Version:6.0.6002.2.2.0.768.3
  Locale ID:2057
  Additional Information 1:482b
  Additional Information 2:fe3cbbb77b564d5f0cb2cc6fc75b3c2f
  Additional Information 3:73f1
  Additional Information 4:1e2657c1444006182528bd2953dbb394

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


[Issue 7293] dmd 2.057 segfault/crash - std.regex.match(string, string)

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7293


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 CC||yebbl...@gmail.com


--- Comment #3 from yebblies yebbl...@gmail.com 2012-01-28 03:44:29 EST ---
On win32 I get the following:

DMD v2.058 DEBUG
..\..\phobos\std\regex.d(6278): Error: malloc cannot be interpreted at compile
t
ime, because it has no available source code
..\..\phobos\std\regex.d(6278):called from here:
enforce(malloc(size),de
legate pure nothrow @safe const(char)[]()
{
return null;
}
)
..\..\phobos\std\regex.d(6449):called from here:
(RegexMatch!(string,Tho
mpsonMatcher) __ctmp919 =
_D3std5regex50__T10RegexMatchTAyaS273std5regex15Thomps
onMatcherZ10RegexMatch6__initZ;
 , __ctmp919).this(regex(re,),input)
testx.d(4):called from here: match(,)

So it might actually be ice_on_invalid code... and also a phobos bug.

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


[Issue 7376] floating point bug

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7376


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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||WORKSFORME


--- Comment #3 from Walter Bright bugzi...@digitalmars.com 2012-01-27 
09:23:42 PST ---
Ok, so without further evidence it is not working in the latest build, I'm
going to resolve this.

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


[Issue 7372] Error provides too little information to diagnose the problem (error: undefined identifier)

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7372


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

   What|Removed |Added

   Severity|normal  |enhancement


--- Comment #3 from Walter Bright bugzi...@digitalmars.com 2012-01-27 
09:28:10 PST ---
It's fundamental to mixing in templates that any scopes it needs to build must
be present in the instantiation context, so yes, the burden is on the designer
of that template to document it.

I'm going to mark this as enhancement because it is working as it was designed
to.

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


[Issue 7372] Error provides too little information to diagnose the problem (error: undefined identifier)

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7372



--- Comment #4 from Leandro Lucarella leandro.lucare...@sociomantic.com 
2012-01-27 09:35:15 PST ---
(In reply to comment #3)
 It's fundamental to mixing in templates that any scopes it needs to build must
 be present in the instantiation context, so yes, the burden is on the designer
 of that template to document it.
 
 I'm going to mark this as enhancement because it is working as it was designed
 to.

Fair enough, but I think the error is really bad, I spent at least 2 hours to
figure out what was going on because of what I explain in comment 2. I  I think
it might deserve a little more than enhancement, but this is a grey area. If
a compiler error says can't compile and nothing else, is that an bug or just
an enhancement? The message is not wrong, but is really bad, like in this case
(at a different level, of course).

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


[Issue 7379] New: DMD segfaults on semantic3 phase when alias enum this;

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7379

   Summary: DMD segfaults on semantic3 phase when alias enum this;
   Product: D
   Version: D2
  Platform: x86_64
OS/Version: Linux
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: nazriel6...@gmail.com


--- Comment #0 from Damian Ziemba nazriel6...@gmail.com 2012-01-27 11:05:07 
PST ---
// -
struct Test 
{

enum ENUM
{
M1,
M2,
M3
}
alias ENUM this;
}

class Test2
{
this(Test test)
{
}

this(string test)
{
this(Test());
}
}

void main() {}
// ---

This code snippet cause DMD to segfault on semantic3 phase.
Backtracing showes that problem occurs in mtype.c: 7804

gdb dmd 
./run -c ./test.d

Full backtrace:
// ---
#0  0x004c6450 in TypeStruct::wildConvTo(Type*) ()
No symbol table info available.
#1  0x004ca02b in TypeFunction::callMatch(Expression*,
ArrayBaseExpression*, int) ()
No symbol table info available.
#2  0x0048e745 in fp2(void*, FuncDeclaration*) ()
No symbol table info available.
#3  0x0048e164 in overloadApply(FuncDeclaration*, int (*)(void*,
FuncDeclaration*), void*) ()
No symbol table info available.
#4  0x0048e22d in overloadResolveX(Match*, FuncDeclaration*,
Expression*, ArrayBaseExpression*) ()
No symbol table info available.
#5  0x0048e2b2 in FuncDeclaration::overloadResolve(Loc, Expression*,
ArrayBaseExpression*, int) ()
No symbol table info available.
#6  0x00488534 in CallExp::semantic(Scope*) ()
No symbol table info available.
#7  0x004ebe7b in ExpStatement::semantic(Scope*) ()
No symbol table info available.
#8  0x004f4254 in CompoundStatement::semantic(Scope*) ()
No symbol table info available.
#9  0x00491ea2 in FuncDeclaration::semantic3(Scope*) ()
No symbol table info available.
#10 0x004f5bd8 in AggregateDeclaration::semantic3(Scope*) ()
No symbol table info available.
#11 0x004b7a00 in Module::semantic3() ()
No symbol table info available.
#12 0x00403aec in main ()
// ---

I've noticed this problem since 2.056.
At the moment using DMD from Git 2.058.

Operating system:
//---
Linux d3 3.0.6-gentoo #1 SMP Sun Oct 9 12:00:00 CEST 2011 x86_64 Intel(R)
Core(TM) i5 CPU M 450 @ 2.40GHz GenuineIntel GNU/Linux
//---

Occurs also on FreeBSD and MacOSX. 
With both -m32 and -m64.
Not tested on Windows tho.

Removing 
//--- 
alias ENUM this;
//---

From test case solves problem.

Best Regards,
Damian Ziemba

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


[Issue 7380] New: Crash trying to use address of variable in struct constructor at module level

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7380

   Summary: Crash trying to use address of variable in struct
constructor at module level
   Product: D
   Version: D2
  Platform: x86
OS/Version: Windows
Status: NEW
  Keywords: ice-on-invalid-code
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: s...@iname.com


--- Comment #0 from Stewart Gordon s...@iname.com 2012-01-27 11:22:22 PST ---
DMD 2.057, Windows Vista 32-bit
--
struct TestStruct {
this(int* d) {}
}

int xm;
auto tsm = TestStruct(xm);
--
C:\Users\Stewart\Documents\Programming\D\Tests\bugsdmd inout_ctor_bug.d
inout_ctor_bug.d(6): Error: static variable xm cannot be read at compile time
--
Problem signature:
  Problem Event Name:APPCRASH
  Application Name:dmd.exe
  Application Version:0.0.0.0
  Application Timestamp:
  Fault Module Name:dmd.exe
  Fault Module Version:0.0.0.0
  Fault Module Timestamp:
  Exception Code:c005
  Exception Offset:0007e672
  OS Version:6.0.6002.2.2.0.768.3
  Locale ID:2057
  Additional Information 1:482b
  Additional Information 2:fe3cbbb77b564d5f0cb2cc6fc75b3c2f
  Additional Information 3:73f1
  Additional Information 4:1e2657c1444006182528bd2953dbb394
--

The error message the compiler actually emits seems correct, but the crash
certainly isn't.

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


[Issue 7381] New: Make auto tail-const

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7381

   Summary: Make auto tail-const
   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 jmdavisp...@gmx.com 2012-01-27 14:40:46 
PST ---
IFTI was recently changed with arrays to be tail-const. It would be useful if
we could do the same with auto. To quote dsimcha from the newsgroup (
http://www.digitalmars.com/d/archives/digitalmars/D/auto_Top-level_Const_Immutable_152877.html
):

The changes made to IFTI in DMD 2.057 are great, but they reveal another 
hassle with getting generic code to play nice with const.

import std.range, std.array;

ElementType!R sum(R)(R range) {
 if(range.empty) return 0;
 auto ans = range.front;
 range.popFront();

 foreach(elem; range) ans += elem;
 return ans;
}

void main() {
 const double[] nums = [1, 2, 3];
 sum(nums);
}

test.d(8): Error: variable test9.sum!(const(double)[]).sum.ans cannot 
modify const
test.d(14): Error: template instance test9.sum!(const(double)[]) error 
instantiating

Of course this is fixable with an Unqual, but it requires the programmer 
to remember this every time and breaks for structs with indirection. 
Should we make `auto` also strip top-level const from primitives and 
arrays and, if const(Object)ref gets in, from objects?

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


[Issue 7355] inout incorrectly resolved if the same type has both mutable and immutable parts

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7355



--- Comment #8 from timon.g...@gmx.ch 2012-01-27 14:44:19 PST ---
This rule should work satisfactory:

- The compiler is required to resolve inout such that the behavior is as if
there were four (five, with inout(const(T)) enhancement in place) separate
overloads. This could be implemented similar to how you propose it, by adding
all of the versions to the overload set, or by using some insights to speed up
the process (not very hard)

- If there would be an ambiguity between the different pseudo overloads:
-- If one of the remaining multiple possibilities is the const version, drop it
-- If one of the possibilities is the inout version, drop it
(-- If one of the remaining multiple possibilities is the inout const version,
drop it)
-- If mutable and immutable are remaining possible matches for inout, resolve
inout to mutable.
-- otherwise resolve inout to what is left.

- Allow direct conversion of the return type to any of the versions of inout
that still match after implicit conversions of the arguments in place.

- An inout function is considered to be less specialized than a corresponding
non-inout one.

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


[Issue 7199] std.string.indexof cannot be compiled with -inline

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7199


Richard Webb we...@beardmouse.org.uk changed:

   What|Removed |Added

 CC||we...@beardmouse.org.uk


--- Comment #4 from Richard Webb we...@beardmouse.org.uk 2012-01-27 15:19:56 
PST ---
If i try to build Juno with the latest DMD/Phobos as of now, i get

Error: function juno.locale.core.Culture.displayName cannot get frame pointer
to simpleMindedFind

(Where displayName calls std.string.indexOf).
It builds ok without -inline.

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


[Issue 7381] Make auto tail-const

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7381


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

   What|Removed |Added

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


--- Comment #1 from timon.g...@gmx.ch 2012-01-27 15:27:42 PST ---
It would make sense in a way, but how would generic code that preserves the
const-ness of some value be written nicely with this in place?

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


[Issue 7381] Make auto tail-const

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7381



--- Comment #2 from Jonathan M Davis jmdavisp...@gmx.com 2012-01-27 15:37:11 
PST ---
Presumably, it would either use the generic type explicitly or use typeof. And
if it really wanted const, then it could just use const explicitly.

If the dropping of constness would make the assignment not possible though, I
would argue that the constness should be kept. So, then as long as the code
isn't in a situation where it doesn't need to keep constness but it _wants_ to,
auto works great. Whereas now, it's really easy to get into a situation where
you end up with a const or immutable variable when you really didn't want one,
just because the template was instatiated with a const or immutable type.

In general though, I think that if you want const or immutable, you use const
or immutable rather than auto. So, the fact that auto preserves full constness
causes far more problems than it would if it just preserved tail-constness.

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


[Issue 7382] New: Static matrix initialization

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7382

   Summary: Static matrix initialization
   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-01-27 15:41:14 PST ---
I'd like D to allow to initialize the fixed-sized B matrix just as A:


double[3] A = 0.0;// OK
double[3][3] B = 0.0; // Error
void main() {
double[3][3] C = 0.0; // OK
}


Currently DMD 2.058head gives:
test.d(2): Error: cannot implicitly convert expression (0) of type double to
double[3u][3u]

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


[Issue 3702] Replace __traits and is(typeof()) with a 'magic namespace'

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3702


bearophile_h...@eml.cc changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc


--- Comment #1 from bearophile_h...@eml.cc 2012-01-27 15:54:21 PST ---
Currently this is the most voted Bugzilla bug (enhancement request).

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


[Issue 7199] std.string.indexof cannot be compiled with -inline

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7199



--- Comment #5 from Trass3r mrmoc...@gmx.de 2012-01-28 00:55:48 CET ---
Richard, yes, see my comment 1 for the reduced version.

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


[Issue 7369] Inout constructor causes compiler to reject invariant

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7369


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 CC||yebbl...@gmail.com


--- Comment #1 from yebblies yebbl...@gmail.com 2012-01-28 15:10:45 EST ---
Well, what should happen?  You can't call a non-const invariant from a const
function (or immutable or inout).  The same issue exists with shared
constructors.

If anyone has a solution, we can use it to solve issue 519 as well.

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


[Issue 3731] Can implicitly cast an immutable reference to a derived class

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3731



--- Comment #6 from github-bugzi...@puremagic.com 2012-01-27 20:24:11 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/7bed81961aefc5327b57be0862514b78d84355db
The fix for issue 3731 shows a couple of places in phobos that rely on this
bug.  std.xml is going away, so work around the issue for now (all problems are
caused by opEquals and opCmp not being const correct) and in std.datetime, AA
values must be rebindable.

https://github.com/D-Programming-Language/phobos/commit/472c2a984391a97fd6fda5b77d082e184b828c87
Merge pull request #408 from yebblies/issue3731

Remove implicit casts to mutable super class

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


[Issue 2819] array.sort segfaults if array length =0x8F_FFFF

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2819



--- Comment #8 from github-bugzi...@puremagic.com 2012-01-27 21:08:32 PST ---
Commit pushed to phobos-1.x at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/12b9cb5db63216c33485681edc83f2f272d869f9
fix Issue 2819 - array.sort segfaults if array length =0x8F_

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


[Issue 2819] array.sort segfaults if array length =0x8F_FFFF

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2819



--- Comment #9 from github-bugzi...@puremagic.com 2012-01-27 21:09:54 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/077c1bd9948dce0a645cc5df5b9dc8919a2295fc
Issue 2819 - array.sort segfaults if array length =0x8F_

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


[Issue 2819] array.sort segfaults if array length =0x8F_FFFF

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2819


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

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||FIXED


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


[Issue 5868] static attribute ignored with public static {} blocks

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5868



--- Comment #10 from hst...@quickfur.ath.cx 2012-01-27 21:12:58 PST ---
Yeah, invalid attributes should not be ignored. They should always generate a
compile-time error. Just as expressions with no side-effects generate an error
when they appear as standalone statements, rather than get ignored.

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


[Issue 5868] static attribute ignored with public static {} blocks

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5868



--- Comment #11 from Jonathan M Davis jmdavisp...@gmx.com 2012-01-27 21:24:48 
PST ---
There are arguments for it which relate to generic programming. It's not that
hard to end up with templated code that would have issues compiling if the
compiler errored out on invalid attributes for particular instantiations of a
template while being fine for others.

I agree that ideally the compiler would error out on invalid attributes, but I
think that the situation and its effects have to be closely examined before
changing the status quo. Regardless of that though, the big problem is
convincing Walter. Personally, I'm surprised that the compiler allows invalid
attributes in the first place. I have no idea what his thought process was in
allowing them and have no idea what it would take to convince him.

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


[Issue 5868] static attribute ignored with public static {} blocks

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5868


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 CC||yebbl...@gmail.com


--- Comment #12 from yebblies yebbl...@gmail.com 2012-01-28 16:40:00 EST ---
(In reply to comment #11)

It's to do with the way the compiler handles attributes.  There are four kinds:

1. shared void func();
2. shared: void func();
3. shared { void func(); }
4. void func() shared;

The first two really evaluate to the third.  It doesn't make sense for the
third one to give an error on invalid attributes, as they might be intended to
a bunch of different declarations.  While the first one looks like is should be
rejected sometimes, to the compiler they're all the same.

The fourth case is special, in that the storage classes get passed directly to
the function declaration.  There is potential here for rejecting invalid
storage classes, but are there any that are actually invalid?

So to answer your question: Having attributes work this way make the parser
compiler simpler.  The decision most likely dates from a time when this was one
of D's major goals.

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


[Issue 1251] Final template class w/ constructor and invariant causes compile error

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1251


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||yebbl...@gmail.com
   Platform|x86 |All
 Resolution||WORKSFORME
 OS/Version|Linux   |All


--- Comment #4 from yebblies yebbl...@gmail.com 2012-01-28 16:46:09 EST ---
I can't get this to fail.  It's most likely been fixed sometime in the last
four years.  Probably in the fixes for similar problems with out contracts.

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


[Issue 7383] New: Blank lines in code sections cause premature section termination

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7383

   Summary: Blank lines in code sections cause premature section
termination
   Product: D
   Version: D1  D2
  Platform: All
OS/Version: All
Status: NEW
  Keywords: ddoc
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: siegelords_ab...@yahoo.com


--- Comment #0 from siegelords_ab...@yahoo.com 2012-01-27 22:40:10 PST ---
Test case (compile it with dmd -D):

/**
---
foo;

foo;
---
 */
void test(); // 2x test.d(8): Error: function test.test unmatched --- in DDoc
comment

/**
---

foo;
---
 */
void test2(); // 2x test.d(16): Error: function test.test2 unmatched --- in
DDoc comment

/**
foo

---

foo;
---
 */
void test3(); // OK

void main() {}

I think I tracked this bug down to line 1119 in doc.c:

if (*p == '\n'  !summary  !namelen)

If I change it to this:

if (*p == '\n'  !summary  !namelen  !inCode)

It compiles the codes above and generates fine HTML. I honestly find the doc.c
code impenetrable, so I don't know if this is the right fix. The line is for
the D2 dmd, but this bug happens in D1 as well.

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


[Issue 6559] Compiler message expression formatting does not match phobos

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6559


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

   Keywords|CTFE|diagnostic
 CC||yebbl...@gmail.com
   Platform|Other   |All
Summary|[CTFE-ish] Inconsistent |Compiler message expression
   |array formatting at runtime |formatting does not match
   |vs compiletime  |phobos
 OS/Version|Windows |All
   Severity|minor   |enhancement


--- Comment #2 from yebblies yebbl...@gmail.com 2012-01-28 18:22:15 EST ---
I agree with Don.  This is asking for dmd's value formatting to match what
phobos currently does.  The fact it doesn't is not a bug.  Does not involve
CTFE.

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


[Issue 7286] Array division bypasses immutable

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7286


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||yebbl...@gmail.com
 Resolution||DUPLICATE


--- Comment #1 from yebblies yebbl...@gmail.com 2012-01-28 18:27:05 EST ---
*** This issue has been marked as a duplicate of issue 4662 ***

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


[Issue 4662] Array ops on const arrays

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4662


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 CC||dsim...@yahoo.com


--- Comment #1 from yebblies yebbl...@gmail.com 2012-01-28 18:27:05 EST ---
*** Issue 7286 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 4662] Array ops on const arrays

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4662


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

   Keywords||accepts-invalid
 CC||yebbl...@gmail.com
   Platform|x86 |All
 AssignedTo|nob...@puremagic.com|yebbl...@gmail.com
 OS/Version|Windows |All


--- Comment #2 from yebblies yebbl...@gmail.com 2012-01-28 18:38:19 EST ---
Looks like the fix for issue 5284 only got assignment.

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