<div dir="ltr"><div>+    // Bail out if the type of the ConstantStruct does not have the same layout</div><div>+    // as the type of the InitListExpr.</div><div>+    if (CGM.getTypes().ConvertType(Field->getType()) != EltInit->getType())</div><div>+      return false;</div><div><br></div><div>I don't think that's quite enough; even if all the types of the `ConstantStruct` match the types of the fields, the fields might be at different offsets (due to an alignment attribute). This could happen if the original initializer initializes one member of a union and the update expression initializes a different member. Use `getStructLayout` on the `DataLayout` object to find the offset of the fields within the `ConstantStruct` and compare them to the offset from the `ASTRecordLayout` object.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 5, 2015 at 5:50 PM, Yunzhong Gao <span dir="ltr"><<a href="mailto:Yunzhong_Gao@playstation.sony.com" target="_blank">Yunzhong_Gao@playstation.sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D5789&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=2iklY29QEKJZ6lGUAVayV-wvu9eOcD1UIvx_XC70xhc&s=aYv3ZoZYbKIh73zOyr01IOWMOSYWbPOoPuNC7JloJ9c&e=" target="_blank">http://reviews.llvm.org/D5789</a><br>
<br>
Files:<br>
  include/clang/AST/DataRecursiveASTVisitor.h<br>
  include/clang/AST/Expr.h<br>
  include/clang/AST/RecursiveASTVisitor.h<br>
  include/clang/Basic/StmtNodes.td<br>
  include/clang/Serialization/ASTBitCodes.h<br>
  lib/AST/Expr.cpp<br>
  lib/AST/ExprClassification.cpp<br>
  lib/AST/ExprConstant.cpp<br>
  lib/AST/ItaniumMangle.cpp<br>
  lib/AST/StmtPrinter.cpp<br>
  lib/AST/StmtProfile.cpp<br>
  lib/CodeGen/CGExprAgg.cpp<br>
  lib/CodeGen/CGExprCXX.cpp<br>
  lib/CodeGen/CGExprConstant.cpp<br>
  lib/Sema/SemaExceptionSpec.cpp<br>
  lib/Sema/SemaInit.cpp<br>
  lib/Sema/TreeTransform.h<br>
  lib/Serialization/ASTReaderStmt.cpp<br>
  lib/Serialization/ASTWriter.cpp<br>
  lib/Serialization/ASTWriterStmt.cpp<br>
  lib/StaticAnalyzer/Core/ExprEngine.cpp<br>
  test/Analysis/designated-initializer.c<br>
  test/CodeGen/partial-reinitialization1.c<br>
  test/CodeGen/partial-reinitialization2.c<br>
  test/PCH/designated-init.c.h<br>
  test/Sema/designated-initializers.c<br>
  test/SemaCXX/decltype.cpp<br>
  tools/libclang/CXCursor.cpp<br>
<br>
EMAIL PREFERENCES<br>
  <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_settings_panel_emailpreferences_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=2iklY29QEKJZ6lGUAVayV-wvu9eOcD1UIvx_XC70xhc&s=_sUhfn5Fb0ppiPQwxsKb4PyG2uVuUzN2YNJGF516N6g&e=" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
</div></div></blockquote></div><br></div>