From 377c0db5d385c38d67bb9b361d200b3781b940d8 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Tue, 13 Oct 2026 17:48:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(gen):=20life=5Fof=5Fexpr=20=E7=9A=84?= =?UTF-8?q?=E6=9E=84=E9=80=A0=E5=88=86=E6=94=AF=E6=8C=89=E7=9B=AE=E6=A0=87?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=88=A4=E5=AE=9A=E2=80=94=E2=80=94=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E4=B8=BA=E5=90=8C=E5=9E=8B=E8=81=9A=E5=90=88=E5=80=BC?= =?UTF-8?q?=E6=97=B6=E5=88=A4=20LIFE=5FVALUE=EF=BC=88=E5=80=BC=E6=8B=B7?= =?UTF-8?q?=E8=B4=9D=EF=BC=89=EF=BC=8C=E4=B8=8D=E5=86=8D=E8=AF=AF=E5=88=A4?= =?UTF-8?q?=E5=B8=A7=E9=80=83=E9=80=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/lib/core/Gen/AssignGenMixin.vp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/App/lib/core/Gen/AssignGenMixin.vp b/App/lib/core/Gen/AssignGenMixin.vp index 99cc14e..d3f4bd7 100644 --- a/App/lib/core/Gen/AssignGenMixin.vp +++ b/App/lib/core/Gen/AssignGenMixin.vp @@ -974,7 +974,14 @@ novirtual class AssignGenMixin: ct_ty: mlirlite.LLVMType* = self.Gen.StructGen.get_struct_type(ctor_nm) if ct_ty is not None: ct_en: GenTypes.StructEntry* = self.Gen.StructGen.find_struct_by_type(ct_ty) - if ct_en is None or ct_en.HasNew == 0: return GenTypes.LIFE_FRAME + if ct_en is None or ct_en.HasNew == 0: + # 裸构造 `T(...)` 的存储是本帧入口 alloca,但**目标位置是同型聚合值**时语义是 + # 值拷贝:返回/写入会把整块聚合复制出去,拷贝与源帧无关 —— 判 LIFE_VALUE + # (与上方裸数组名的口径一致)。只有裸构造退让成指针的位置(`&T(...)`、指针目标、 + # 异型聚合目标)才交出本帧地址,判 LIFE_FRAME。 + if target_ty is not None and self.Gen.ExprGenBase.is_ptr_type(target_ty) == 0: + if self._stg_ty_equal(trans.Pool, ct_ty, target_ty) != 0: return GenTypes.LIFE_VALUE + return GenTypes.LIFE_FRAME return GenTypes.LIFE_UNKNOWN if k == ast.ASTKind.New: # M2.4 `new`:生命期由描述符决定(§2.3 组合矩阵)