# Gate 204 (run linkw wave C, lane cat-ov002): the ov002 DELETING DESTRUCTORS
# the port hand-spelled or declined -- slot 17 on three seated ov002 classes.
#
# WHAT SLOT 17 IS AND WHY IT WAS EMPTY. Slot 16 is the complete-object
# destructor (D1) and slot 17 the deleting one (D0): the same member chain plus
# a Memory::Deallocate of the object. The ROM's destroy path runs D1 through
# slot 16 and lets ActorBase::AfterCleanupResources do the deallocation, so
# nothing in the game dispatches slot 17 -- which is exactly why every ov002
# seat in this port left it on a trap (bw_trap17) or hand-spelled it. Neither
# is the ROM's word. The ROM's word is the class's own D0 body, and each of the
# three below is a matched TU sitting in src/ with nothing referencing it.
#
# THIS IS THE w2_dtor_heads ARGUMENT, applied per class instead of per table:
# Release links with /OPT:REF, so a matched TU on a slice line with no
# reference is dropped before the map is written. A ROM vtable slot the port
# never filled is the honest place to put the reference, because the ROM says
# what belongs there.
#
# BEHAVIOUR. Coin, HealingHeart and Cap all sat on bw_trap17, which declines by
# name; PushBlock had a host thunk spelling the chain by hand. Nothing
# dispatches slot 17 on any of them, so what changes is that the port's copy of
# each table now carries the word the ROM puts there, and the hand-spelled copy
# of PushBlock's chain is replaced by the body it was transcribed from.
#
# EACH BODY, AND WHY IT COMPILES AS-IS (all three are flat C, none carries the
# inferred-stub marker, and every callee is already in walk_window.map):
#
#   _ZN11PowerFlowerD0Ev      ov002 0x020b9198, slot 17 of _ZTV9PushBlock
#       WithMeshClsn +0x200, MovingCylinderClsn +0x1cc, ShadowModel +0x174,
#       Model +0x124, Model +0xd4, Actor::D2, Deallocate. Spells its table by
#       the RTTI name _ZTV18daObjPowerUpItem_c, which
#       hal/actor_classes_ov002g200.cpp already aliases onto _ZTV9PushBlock.
#       hal's pb_d0 was this chain typed out by hand; it now calls this body.
#
#   _ZN12HealingHeartD0Ev        ov002 0x020bc618, slot 17 of _ZTV7Seaweed
#       MovingCylinderClsn +0x138, ModelAnim +0xd4, Actor::D2, Deallocate.
#       _ZTV7Seaweed is HEALING_HEART's table (RTTI 12daObjHeart_c, the ov002
#       name shift hal/actor_classes_bob_world.cpp derives at its head); the
#       body spells it by the RTTI name and the alias for that spelling is new
#       with this gate.
#
#   _ZN15daObjMarioCap_cD0Ev ov002 0x020b6f68, slot 17 of _ZTV13WaterfallMist
#       _ZN10dCapIcon_cD1Ev +0x3d0, ShadowModel +0x364, ModelAnim +0x300,
#       WithMeshClsn +0x144, MovingCylinderClsn +0x110, _ZN12dEnemyBase_cD2Ev,
#       Deallocate. _ZTV13WaterfallMist is THE CAP's table (RTTI
#       15daObjMarioCap_c), not the class gate 20 fills; same new-alias note.
#       This one ends in _ZN12dEnemyBase_cD2Ev rather than Actor::D2 directly,
#       which is Enemy's D2 -- the cap is an Enemy subclass.
#
# COIN'S D0 NEEDS NO LINE HERE. src/_ZN4CoinD0Ev.cpp has been on slice_gate33.txt
# since that gate and was /OPT:REF-stripped for want of a reference; the seat
# in hal/actor_classes_bob_world.cpp is the whole of its change.
#
# ===========================================================================
# THIS GATE SUPERSEDES A STANDING RULING. READ THIS BEFORE THE NEXT SLOT 17.
# ===========================================================================
#
# port/slice_w1l1.txt section (2) declines four slot-17 seats and states the
# convention in the port's own words: AfterCleanupResources dispatches slot 16
# and performs the Deallocate itself, so a landing on the deleting form means
# something reached the actor through operator delete, the trap is the bug
# report, and "seating them replaces a diagnostic with a double free". It names
# _ZN4CoinD0Ev as one of the four, and records that lane l5 made the same call
# for _ZN6PlayerD0Ev and lane l3 for _ZN11ShadowModelD0Ev.
#
# This gate seats Coin's. That is a reversal, not an oversight, and the reason
# the ruling was too wide is a distinction it does not draw: THERE ARE TWO
# KINDS OF SLOT-17 TRAP IN THIS PORT AND THEY COST DIFFERENT THINGS.
#
#   SOFT. bw_trap17 / ac_trap17 / wf_trap17 print one line and call
#         port_actor_slot_decline. The quarantine net catches it, the actor
#         freezes for the rest of the level, the game continues. The diagnostic
#         value is real but bounded, and it is bounded by something else too:
#         it only ever fires if a dispatch exists.
#   HARD. ps_trap, the Player's, calls std::abort(). That is a live misuse
#         detector: it stops the process at the first `delete` that should
#         never have happened, which is worth strictly more than a leak.
#
# THE DISPATCH COUNT IS ZERO, AND THAT IS MEASURED, NOT REASONED. A slot-17
# dispatch through a hosted 31-slot table is an indirect call at byte offset
# 0x44. Sweeping the whole linked binary:
#
#     dumpbin /disasm:nobytes build/port/walk_window.exe
#       call/jmp dword ptr [reg+44h]   0 sites   <- slot 17, nothing dispatches
#       call/jmp dword ptr [reg+40h]   1 site    <- slot 16, positive control
#
# and the single slot-16 site resolves through walk_window.map to 0x004df5d0,
# ?AfterCleanupResources@fBase_c@@UAEXI@Z -- which is exactly the function
# the w1l1 ruling names as the one that dispatches 16 and deallocates itself.
# So the control proves the sweep can see this shape, and the zero is a real
# zero rather than a pattern that does not match.
#
# THE GOING-FORWARD CONVENTION, so the next lane cites one rule and not
# whichever of two it finds first:
#
#   Unseating a SOFT slot-17 trap is allowed when all three hold:
#     (a) the ROM's own word at table+0x44 is that class's D0, read from the
#         overlay image rather than from a recovered name;
#     (b) the matched body carries no inferred-stub marker and its whole
#         callee closure is already in the map;
#     (c) the binary-wide [reg+44h] dispatch count is still zero, re-measured
#         against the build being changed.
#   A HARD trap (std::abort) is never unseated on these grounds. Player's slot
#   17 stays exactly as level_boot.cpp has it; the abort is the feature.
#
# SCOPE, because the ruling had a second reason this does not touch.
# _ZN9LightBeamD0Ev is declined in w1l1 for a different and stronger cause: the ROM
# shares that body across two object layouts and it fits LIGHT_BEAM's only, so
# on a 944-byte TRAP its 0xd4/0x124 chain smashes Platform's fields. That is a
# correctness fault in the body, not a diagnostic trade, and nothing here
# unblocks it. Same for any slot-17 body whose layout is shared.
# RETIRED at SLICE1: body now in src/_ZN11PowerFlowerD1Ev.cpp. MSVC folds the ROM destructor variants into one symbol, so only one of a class two per-function destructor TUs can be compiled.
#src/_ZN11PowerFlowerD0Ev.cpp
# RETIRED at SLICE1: body now in src/_ZN12HealingHeartD1Ev.cpp. MSVC folds the ROM destructor variants into one symbol, so only one of a class two per-function destructor TUs can be compiled.
#src/_ZN12HealingHeartD0Ev.cpp
src/actors/daObjMarioCap_c.cpp
