News for hackers. Stuff that matters.
Re:Stop Memsetting Structures by saagarjha on Sunday April 28, 2019 @07:55AM (#19770620)
A conforming C compiler can remove a memset that has no side effects.
Re:Stop Memsetting Structures by jcr1488 on Sunday April 28, 2019 @08:27AM (#19770765)
You mean it can remove a memset() that doesn't cause the observable behaviour to change?

For the sake of argument, can you show me some example code where it would be conforming to remove a memset() call? Preferably a realistic example and not a Google'd copypasta. Because it's all too easy to just regurgitate things you heard and think you understood, but no so easy to demonstrate it yourself.

Re:Stop Memsetting Structures by nkurz on Sunday April 28, 2019 @08:40AM (#19770822)
I agree that it would be rare for a memset() used for initialization to be removed, but this is a good recent paper that gives lots of examples of when stores are eliminated in practice:

Dead Store Elimination (Still) Considered Harmful

https://cseweb.ucsd.edu/~klevchen/yjoll-usesec17.pdf