Weird codegen bug

Dennis dkorpel at gmail.com
Thu Jun 13 12:03:33 UTC 2019


On Thursday, 13 June 2019 at 11:28:25 UTC, RazvanN wrote:
> Is this a bug or am I missing something? For the record,
> gdc prints (as expected):

What happens is that b lives in a register.
After the first call, the register is invalidated and it has to 
be reloaded with the value on the stack (modified by your 
pointer).

I'm pretty sure *(&a + 1) = 2; is undefined behavior, so both dmd 
and gdc are correct.

(Assembly can be seen here: https://run.dlang.io/is/bjxVXg)


More information about the Digitalmars-d mailing list