Thread overview |
---|
March 30 [Issue 24469] non-constant nested delegate literal expression - Error on delegates causing memory corruption | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24469 --- Comment #1 from Marcelo Silva Nascimento Mancini <msnmancini@hotmail.com> --- I was able to reduce the bug: ```d struct ExistenceChecker { ///Optional. bool delegate() checkExistenceFn; } ExistenceChecker makeExistenceChecker(string gemName) { return ExistenceChecker(() { return executeShell("gem list | grep "~gemName).status == 0; }); } ExistenceChecker[] chks = [ makeExistenceChecker("test") ]; ``` -- |
March 30 [Issue 24469] non-constant nested delegate literal expression - Error on delegates causing memory corruption | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24469 kinke <kinke@gmx.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kinke@gmx.net --- Comment #2 from kinke <kinke@gmx.net> --- Full example, showing the crash with DMD (LDC issues a compile error instead - 'Error: non-constant nested delegate literal expression `__lambda2`'): ``` struct ExistenceChecker { bool delegate() checkExistenceFn; } ExistenceChecker makeExistenceChecker(string gemName) { return ExistenceChecker(() => gemName == "dummy"); } auto checker = makeExistenceChecker("test"); // => invalid non-constant initializer void main() { assert(!checker.checkExistenceFn()); } ``` -- |
March 30 [Issue 24469] non-constant nested delegate literal expression - Error on delegates causing memory corruption | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24469 kinke <kinke@gmx.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|critical |regression --- Comment #3 from kinke <kinke@gmx.net> --- Oh and this is a regression according to run.dlang.io - up to v2.078, DMD issued a 'Error: non-constant nested delegate literal expression `__lambda2`' error too; since v2.079, it allows compilation but crashes at runtime. -- |
Copyright © 1999-2021 by the D Language Foundation