June 28, 2023 [Issue 24021] New: Issue a warning on assert with side effects | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24021 Issue ID: 24021 Summary: Issue a warning on assert with side effects Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: grimmaple95@gmail.com Consider this code: ``` bool fn(out int a) { a = 10; return true; } void main() { int a; assert(fn(a)); writeln(a); } ``` This code will behave differently in Release and Debug builds. I suggest issuing a warning for the user, when caling functions with side-effects inside an assertion. I'm aware of 6074, and I'm not talking about changing how asserts work, but it would be great to have a warning about this. -- |
Copyright © 1999-2021 by the D Language Foundation