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

--- Comment #39 from yebblies <[email protected]> ---
(In reply to bearophile_hugs from comment #37)
> (In reply to yebblies from comment #36)
> 
> > Try it, look at the asm.  No memory allocation.
> 
> The asm is not enough. @nogc is a purely front-end thing, to avoid different
> optimizations in different compilers to lead to @nogc-annotated code to
> compile or not compile in different compilers. So this problem is not a bug,
> it's an enhancement request, to add this optimization in the front-end.

As nice as that all sounds, the reality is that the dmd frontend currently
defines which optimizations are guaranteed by the frontend.

There are many places where const-folding already affects semantics (especially
implicit conversions).

Tying improving the usability of @nogc to a mythical optimization spec will
likely only achieve preventing improvement to the usability of @nogc.

> to add this optimization in the front-end.

That is exactly where const-folding is done.

--

Reply via email to