[Issue 24021] Issue a warning on assert with side effects
https://issues.dlang.org/show_bug.cgi?id=24021 Basile-z changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|DUPLICATE |--- --- Comment #8 from Basile-z --- indeed, subtle difference. --
[Issue 24021] Issue a warning on assert with side effects
https://issues.dlang.org/show_bug.cgi?id=24021 --- Comment #7 from Grim Maple --- With all due respect, this isn't a _duplicate_ of 12028. I'm not proposing to disallow side effects, I'm proposing to notify user that their code was not compiled. I think this warning should be issued in release builds only, as they are the only one affected. This will not affect unittests or bring other inconveniences. Besides, maybe, rewriting code from `assert(foo())` to `auto tmp = foo(); assert(tmp);` --
[Issue 24021] Issue a warning on assert with side effects
https://issues.dlang.org/show_bug.cgi?id=24021 Basile-z changed: What|Removed |Added Status|NEW |RESOLVED CC||b2.t...@gmx.com Resolution|--- |DUPLICATE --- Comment #6 from Basile-z --- *** This issue has been marked as a duplicate of issue 12028 *** --
[Issue 24021] Issue a warning on assert with side effects
https://issues.dlang.org/show_bug.cgi?id=24021 Tim changed: What|Removed |Added CC||tim.dl...@t-online.de --- Comment #5 from Tim --- This seems to be a duplicate of issue 12028. --
[Issue 24021] Issue a warning on assert with side effects
https://issues.dlang.org/show_bug.cgi?id=24021 mhh changed: What|Removed |Added CC||maxha...@gmail.com --- Comment #4 from mhh --- Pretty sure warnings have been added. --
[Issue 24021] Issue a warning on assert with side effects
https://issues.dlang.org/show_bug.cgi?id=24021 Nick Treleaven changed: What|Removed |Added CC||n...@geany.org --- Comment #3 from Nick Treleaven --- Also asserts are used in unit tests where having side effects is often deliberate. --
[Issue 24021] Issue a warning on assert with side effects
https://issues.dlang.org/show_bug.cgi?id=24021 --- Comment #2 from RazvanN --- This could be implemented by a third party tool using dmd as a library. But I don't think it should be implemented in the compiler. --
[Issue 24021] Issue a warning on assert with side effects
https://issues.dlang.org/show_bug.cgi?id=24021 RazvanN changed: What|Removed |Added CC||razvan.nitu1...@gmail.com --- Comment #1 from RazvanN --- Note: Walter is against issuing warnings. The compiler should either accept or reject your code. A warning is something vague that programmers usually ignore (against what best practices advice). In the last 7 years there were exactly 0 warning added to the compiler. With that being said, there is no way such code is ever going to be an error. That would mean that any function that receives an out parameter (or a pointer/ref parameter) would have to issue an error if used in an assert. That is very restrictive. Even if it were issued as a measly warning, I don't really see the usefulness of it. Asserts have the purpose to test for a specific condition, in this particular case, that a function returns a specific value. Why would a warning be issued if a function receives a pointer parameter? What's the actionable item for this message? Stop using the assert? --