Repository navigation
Fix the size passed to sized delete when an array new constructor throws [GH #551] - #564
lexx42xxel wants to merge 1 commit into
Conversation
…hrows [GH edgcpp#551] The size argument of the deallocation call that frees the storage when an element constructor throws was a reusable copy of the (discarded) size argument of the allocation, which could refer to an uninitialized temporary. The size argument is invariant, so copy it directly (this is asserted). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
AcknowlEDG review results updated for
|
|
AcknowlEDG review results updated for
CI success. |
Fixes the problem reported in triage discussion #551.
Problem and fix
The size argument of the deallocation call that frees the storage when an
element constructor throws was a reusable copy of the (discarded) size
argument of the allocation, which could refer to an uninitialized
temporary. The size argument is invariant, so copy it directly (this is
asserted).
Alternatives considered
Re-evaluate the size expression at cleanup time. Rejected: it may involve temporaries and side effects; the size is invariant once allocated, so copying it (asserted) is simpler and safe.
Tests
New:
tests/tests/regressions/array-new-throw-sized-delete.sft.cpp.Verified failing on main and passing with the fix (IA-64 and non-IA-64 builds); reproducer in the discussion.
AddressSanitizer: the discussion's reproducer (ASan variant) reports
new-delete-type-mismatchon main; no report with the fix or with g++.Checklist
Commits are tagged
[GH #551]with the discussion number; happy to retag once an issue is opened.[GH #551].src/pending_changes/gh-551-array-new-throw-sized-delete.txt.edg-docker-test --posture=extensive(edg_x86_64, edg_x86_64_cp, edg_x86_32, edg_x86_32_cp): no regressions; recordings updated with-W.Summary by CodeRabbit