No, stack allocation should not destroyed

Steven Schveighoffer schveiguy at gmail.com
Tue Jul 19 15:06:04 UTC 2022


On Tuesday, 19 July 2022 at 11:00:58 UTC, Hipreme wrote:

> ```d
> void setUniform(string uniformName, float[2] vec);
> void setUniform(string uniformName, float[3] vec);
> void setUniform(string uniformName, float[4] vec);
> ```
>
> What happens if I do:
> ```d
> void setupRenderer() @nogc
> {
>     setUniform("Test", [1, 2]);
>     setUniform("Test", [1, 2, 3]);
>     setUniform("Test", [1, 2, 3, 4]);
> }
> ```
>
> Then what it happens?
> Error: `@nogc` function `setupRenderer` cannot call non- at nogc 
> function `renderer.setUniform`
> Error: `@nogc` function `setupRenderer` cannot call non- at nogc 
> function `renderer.setUniform`
> Error: `@nogc` function `setupRenderer` cannot call non- at nogc 
> function `renderer.setUniform`

Note how this is not complaining about the allocation of the 
array in `setupRenderer`, it's complaining about `setUniform`

if `setUniform` is truly `@nogc`, properly add the attribute and 
it will work.

-Steve


More information about the Digitalmars-d mailing list