October 30, 2023 [Issue 24211] New: Const nested function can mutate context | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24211 Issue ID: 24211 Summary: Const nested function can mutate context Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: snarwin+bugzilla@gmail.com As of DMD 2.105.2, the following program compiles: --- void main() { int n; void fun() const { n = 123; } } --- Despite being a const function, `fun` is allowed to mutate its context. If fun is made immutable instead of const, the program does not compile. Possibly a duplicate of issue 16248 or issue 18566. -- |
Copyright © 1999-2021 by the D Language Foundation