On Thu, 12 Sept 2024 at 04:26, Walter Bright via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
On 9/11/2024 3:23 PM, Manu wrote:
> Even if you can manage to convince a compiler to write the output you're
> alleging,

Alleging? I cut and pasted what dmd did and what gcc did. My gcc may behave
differently than yours, as there are many versions of it.

This is literally my point...

> I would never imagine for a second that's a reliable strategy. The
> optimiser could do all kinds of things... even though in all my experiments, it
> does exactly what I predicted it would.

Did you use -O?

I used -O2... I don't imagine that would have made a difference though? I don't think I've ever seen anyone use -O before.

dmd does what I predicted it would, as it is designed to operate that way. If
gcc doesn't do what you want, there's nothing I can do about it.

You're not meant to do anything about it; just accept that your suggestion to rely on contorting the code and a prayer that the compiler emits the code you'd like to see (it doesn't) is not a reasonable suggestion.
This needs a proper solution.