[PATCH] D61280: Variable auto-init: don't initialize aggregate padding of all aggregates

JF Bastien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 30 13:58:06 PDT 2019


jfb added a comment.

In D61280#1485115 <https://reviews.llvm.org/D61280#1485115>, @rjmccall wrote:

> I don't think the implication is supposed to be that padding is zero-initialized or not depending on where in the aggregate it appears, but it doesn't really matter, I don't think we're arguing about the goal of this patch.


The way I read it, C guarantees that an aggregate's padding is zero-initialized when you use brace-enclosed list *unless* you've mentioned all the elements / members of the aggregate. Fail to mention one → padding must be zero. Mention all of them → padding isn't guaranteed.

But then *reading* padding is another story. What triggered this change is C code that used `memcmp` on a struct with padding, and was expecting padding to be set. Not great code, but AFAICT technically correct.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61280/new/

https://reviews.llvm.org/D61280





More information about the cfe-commits mailing list