================
@@ -7357,11 +7357,12 @@ ConstantAddress CodeGenModule::GetAddrOfGlobalTemporary(
E->getStorageDuration() == SD_Thread) && "not a global temporary");
const auto *VD = cast<VarDecl>(E->getExtendingDecl());
- // If we're not materializing a subobject of the temporary, keep the
- // cv-qualifiers from the type of the MaterializeTemporaryExpr.
- QualType MaterializedType = Init->getType();
- if (Init == E->getSubExpr())
- MaterializedType = E->getType();
+ // Keep cv-qualifiers from the MaterializeTemporaryExpr on the storage type.
+ // The initializer expression may have had rvalue subobject adjustments
+ // stripped, which can drop top-level qualifiers that are still part of the
+ // materialized temporary's type.
+ QualType MaterializedType = getContext().getQualifiedType(
----------------
Takashiidobe wrote:
Great find, I never knew this changed in C++11. I added the change and added
some tests that exercise some extra edge cases including mutable cases.
https://github.com/llvm/llvm-project/pull/186594
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits