================
@@ -727,6 +729,44 @@ void InitListChecker::FillInEmptyInitForField(unsigned 
Init, FieldDecl *Field,
     if (hadError || VerifyOnly) {
       // Do nothing
     } else if (Init < NumInits) {
----------------
zygoloid wrote:

Hmm, how does that work? If this `if` condition doesn't hold and we created an 
`ImplicitValueInitExpr`, we wouldn't produce the warning.

Ah, I see what's happening: the `if` condition on line 736 is always true, 
because since cb77930d6b20e53c735233eecf4572a1c30eb0c0 we always resize the 
init list for a struct to be large enough for all fields, and our optimization 
to leave off trailing struct members was (accidentally, I think) removed. And 
we can see the optimization [stops working between Clang 3.6 and Clang 
3.7](https://godbolt.org/z/fecM1K7Ec).

Given that we've been living without that optimization for 8 years and no-one 
seems to have noticed, I suppose that it's fine that we've lost it, but it 
looks like this function can be simplified a bit as a result. Half of the `if` 
condition on line 674 is always false, and this `if` condition is always true. 
Maybe consider changing the L674 condition to an `assert(Init < NumInits)` and 
simplify this too?

https://github.com/llvm/llvm-project/pull/70829
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to