Bug 18090 – missleading Error-Message when assigning pointers in @safe struct

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-12-16T20:12:38Z
Last change time
2024-12-13T18:55:35Z
Assigned to
No Owner
Creator
Johannes Nordhoff
Moved to GitHub: dmd#19349 →

Comments

Comment #0 by mephisto — 2017-12-16T20:12:38Z
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.
Comment #1 by robert.schadek — 2024-12-13T18:55:35Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19349 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB