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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SF5eS5QDNexLksRDeDZvwY
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-08-30 00:02:14 +02:00
1 parent 23ee83b770
commit febccfc857
1 file changed
+6 -5
+6 -5
View File
@@ -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 | | `1` | Destroy and free - what `delete` compiles to | A handful |
| `0` | Destroy a base-class subobject | 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 `0` and `-1` are a caller-side distinction: the destructors examined here only test the sign, so
them; the distinction presumably matters for classes with virtual bases, which these binaries both simply mean "don't free", but the compiler still passes `0` specifically when destroying a
don't appear to contain. Constructors in these binaries take only `this` (and also return it) - base subobject and `-1` everywhere else. Treat `0` as "this call is destroying me as somebody's
for a class with virtual bases they are said to take a similar flag, but that isn't confirmed base" when reading a call site, even though the callee can't tell.
here.
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 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 away without separate deleting and non-deleting destructors: a virtual `delete` passes 1 through