[Issue 24021] Issue a warning on assert with side effects

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 28 13:03:58 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=24021

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
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?

--


More information about the Digitalmars-d-bugs mailing list