http://d.puremagic.com/issues/show_bug.cgi?id=9080
Summary: DMD compile ambiguous code or doesn’t even warn
Product: D
Version: D2
Platform: x86_64
OS/Version: Linux
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Dimitri Sabadie <[email protected]> 2012-11-25
10:45:10 PST ---
Description:
Here’s a little snippet D code:
import std.stdio : writefln;
abstract class A {
int a;
}
class B : A {
this(int a) {
a = a;
}
}
int main() {
auto b = new B(314);
writefln("value: %d", b.a);
return 0;
}
Compiling it with:
dmd -debug -w -wi auto_aff.d
DMD fails to figure out the auto-affectation. The fact that it either:
1. compiles and has an obviously but hard to find incorrect behavior ;
2. compiles and segfault if `a' is a class or struct for instance.
If we go with in int a, DMD figures it out. So, I think a warning should be
appreciated for that behavior.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------