assert(false) and GC
Ali Çehreli
acehreli at yahoo.com
Fri Jul 9 22:53:10 UTC 2021
On 7/8/21 11:11 AM, DLearner wrote:
> Hi
>
> Please confirm that:
> `
> assert(false, __FUNCTION__ ~ "This is an error message");
> `
>
> Will _not_ trigger GC issues, as the text is entirely known at compile
> time.
>
> Best regards
One way of forcing compile-time evaluation in D is to define an enum
(which means "manifest constant" in that use). I used @nogc to prove
that there is no GC allocation as well:
@nogc
void main() {
enum msg = __FUNCTION__ ~ "This is an error message";
assert(false, msg);
}
Ali
More information about the Digitalmars-d-learn
mailing list