Bug 9080 – Reject effect-free assignment

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2012-11-25T10:45:00Z
Last change time
2012-12-20T15:03:53Z
Assigned to
nobody
Creator
dimitri.sabadie

Comments

Comment #0 by dimitri.sabadie — 2012-11-25T10:45:10Z
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.
Comment #1 by timon.gehr — 2012-11-25T11:21:19Z
No ambiguity, changed title.
Comment #2 by andrej.mitrovich — 2012-12-20T15:03:53Z
In the future please do not mark bugs as x86_64 and OS-specific if they bugs are not tied specifically to those systems. *** This issue has been marked as a duplicate of issue 4407 ***