[Issue 18090] New: missleading Error-Message when assigning pointers in @safe struct
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Dec 16 20:12:38 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=18090
Issue ID: 18090
Summary: missleading Error-Message when assigning pointers in
@safe struct
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: mephisto at nordhoff-online.de
file: app.d
~~~~~~~~~~~~~~~~~~~~~
void main() {
A a = A( true);
}
@safe
struct A {
bool *lala;
this( bool i) {
lala = &aVar;
}
bool aVar = true;
}
~~~~~~~~~~~~~~~~~~~~~
$ dmd --version
DMD64 D Compiler v2.077.1
...
$
$ dmd app.d
app.d(13): Error: address of variable this assigned to this with longer
lifetime
$
The error message makes sense, but it may take a while to see the problem.
Maybe it would be worth mentioning that `this` is a value type who can be
copied.
--
More information about the Digitalmars-d-bugs
mailing list