assert(false) and GC

jmh530 john.michael.hall at gmail.com
Thu Jul 8 18:39:37 UTC 2021


On Thursday, 8 July 2021 at 18:11:50 UTC, 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

Consider below. Only z will generate an error. This is called 
string literal concatenation, which comes from C [1].

```d
@nogc void main() {
     string x = __FUNCTION__ ~ "This is an error message";
     string y = "This is an error message";
     string z = __FUNCTION__ ~ y;
}
```

[1] 
https://en.wikipedia.org/wiki/String_literal#String_literal_concatenation


More information about the Digitalmars-d-learn mailing list