Is it guaranteed that memset will zero out the padding bits in a structure?

后端 未结 3 2363
独厮守ぢ
独厮守ぢ 2021-02-20 16:54

In general ,as per C standard is it guaranteed that memset() with 0 will zero out the padding bits in a C structure?

What about gcc?

For example , something lik

3条回答
  •  北海茫月
    2021-02-20 17:34

    Perhaps worth noting that memset doesn't know anything about your struct (or array, or primitive, or any chunk of memory whatsoever that you happen to unleash it on), so even if it wanted to leave the padding bits intact, it wouldn't even know where they are.

提交回复
热议问题