[Issue 18002] assert subverts the type system with the messages that it accepts

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 23 10:06:39 UTC 2022


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

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

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

--- Comment #5 from RazvanN <razvan.nitu1305 at gmail.com> ---

The compiler attempts to implicitly cast to `const(char)[]`. Since the assert
does not actually modify the message that should be fine, however, because the
lowering to _d_assert_msg is done in the gluelayer it does not check the type
of the message argument (if the frontend did not reject the code it means that
the implicit cast to const(char)[] was possible).

This seems a bit iffy, however, I don't see this as being a problem in @safe
code.

> See the code I posted in issue #18003.  The compiler should reject any attempt to pass a slice of a local variable to assert().

That behavior has now been deprecated provided that the function is marked
@safe.

--


More information about the Digitalmars-d-bugs mailing list