On 3/28/23 12:15, Kalamatee via Gcc-help wrote:
Now, I can work around this by using "+" (even though I don't read the variable), or initializing the value a second time in the asm block - but should I have to?
Yes.
This sounds like the compiler is doing the wrong thing based on the assertion/assumption "=" means I will 100% change some variable,
That's what you've told GCC you will do. GCC doesn't look inside the asm statement to see if you really do it.
and worse after optimizing the code and creating a case where I now have an uninitialized variable being used - does not warn me this is happening?
You've told GCC that you initialized the variable, and GCC believes you. If you lie to the compiler, it will get its revenge. > Would it not be better to interpret "=" to mean "may" change the value, > which would prevent it incorrectly optimizing the initialization away, or > if it does warn that the value may be used uninitialized? If we did that we'd have to add another pattern which means "definitely initialized". That would greatly complicate data flow analysis, for no very good reason. -- Andrew Haley (he/him) Java Platform Lead Engineer Red Hat UK Ltd. <https://www.redhat.com> https://keybase.io/andrewhaley EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671