From febccfc857f04b3b8193cec9ec50f662c5b53285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 30 Aug 2026 00:02:14 +0200 Subject: [PATCH] docs: clarify that the destructor flag 0 vs -1 is a caller-side convention Both mean "do not free" as far as the callee is concerned - it only tests the sign - but 0 is passed specifically for base-subobject destruction. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01SF5eS5QDNexLksRDeDZvwY --- docs/CodeWarriorMangling.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/CodeWarriorMangling.md b/docs/CodeWarriorMangling.md index 5a52971316..b7bd52b43a 100644 --- a/docs/CodeWarriorMangling.md +++ b/docs/CodeWarriorMangling.md @@ -227,11 +227,12 @@ The values that actually get passed, counted over the call sites in a retail bin | `1` | Destroy and free - what `delete` compiles to | A handful | | `0` | Destroy a base-class subobject | A handful | -Only the sign is tested in the destructors examined here, so `-1` and `0` behave identically in -them; the distinction presumably matters for classes with virtual bases, which these binaries -don't appear to contain. Constructors in these binaries take only `this` (and also return it) - -for a class with virtual bases they are said to take a similar flag, but that isn't confirmed -here. +`0` and `-1` are a caller-side distinction: the destructors examined here only test the sign, so +both simply mean "don't free", but the compiler still passes `0` specifically when destroying a +base subobject and `-1` everywhere else. Treat `0` as "this call is destroying me as somebody's +base" when reading a call site, even though the callee can't tell. + +Constructors in these binaries take only `this` (and also return it). Note that the vtable slot holds this same function, flag and all, which is how CodeWarrior gets away without separate deleting and non-deleting destructors: a virtual `delete` passes 1 through