3 ms·
Any particular compiler and command-line setting where it is not optimized away tells you nothing about what that or some other compiler may do in a different r
by ncmncm 5y ago
Any particular compiler and command-line setting where it is not optimized away tells you nothing about what that or some other compiler may do in a different release or command-line setting.
Talk to any core compiler implementer, and they will say that the optimization is allowed. No compiler performs all permitted optimizations, in any release, but the set of those each does do, varies.
- josephcsible 5y ago> Any particular compiler and command-line setting where it is not optimized away tells you nothing about what that or some other compiler may do in a different release or command-line setting. Can you provide a different program, compiler/version, and command line where it will be optimized away? > Talk to any core compiler implementer, and they will say that the optimization is allowed. Are you just guessing that they'll say this, or have they actually said this? If the latter, can you link to where they did? > No compiler performs all permitted optimizations, in any release, but the set of those each does do, varies. My Godbolt link is a really obvious, easy place that the optimization you claim is possible could be performed. I think the fact that none of the 4 major compilers optimized it away is decent evidence that it isn't allowed.
- ncmncm 5y ago> have they actually said this? If the latter, can you link to where they did? They have said it face-to-face, in person. It is possible that, with enough pushback, they have since disabled the optimization. (They all work at large corporations, nowadays, and must obey management direction.) Or, more likely, disabled certain cases of it. I will ask again. For documentary evidence, you may consult the definition of C11 memset_s, which is specified not to permit the optimization. It is hard to imagine such a requirement being perceived as needed, absent cases where calls to memset have actually been elided. I will also experiment further with Godbolt. You might have failed to tickle the compilers in just the right way.
- josephcsible 5y ago> They have said it face-to-face, in person. [...] I will ask again. If you do ask again, can you do so somewhere like a public mailing list, so I can read their response myself? > For documentary evidence, you may consult the definition of C11 memset_s, which is specified not to permit the optimization. It is hard to imagine such a requirement being perceived as needed, absent cases where calls to memset have actually been elided. The point of memset_s is to prohibit the optimization when the object isn't volatile.