`<exception>`: Optimize `exception_ptr` operations #6403
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.44) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 227 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.325
Real PR Conversation Timeline
1 comments
"Review active on #6403"
general
weight: 0.35
YexuanXiao
Summary
Optimizes several
std::exception_ptroperations that currently call out-of-line CRT helpers even though the representation is already known in<exception>.This change:
nullptr_tconstructor rely on the existing null member initializersoperator bool()as_Data1 != nullptr_Data1directly inoperator==_Data1and_Data2directlynullptr_tusing swap-with-empty, avoiding__ExceptionPtrAssignThe exported CRT helper functions remain unchanged for ABI compatibility.
Fixes #6387.
Rationale
exception_ptris intentionally laid out to matchshared_ptr<const _EXCEPTION_RECORD>. Its two data members correspond to the shared pointer's stored pointer and control block, and the implementation already contains astatic_assertenforcing matching size and alignment.The removed out-of-line calls currently perform operations equivalent to the inlined implementations above:
__ExceptionPtrCreatedefault-constructs an emptyshared_ptr__ExceptionPtrToBoolconverts the underlyingshared_ptrtobool__ExceptionPtrComparecompares the underlyingshared_ptr__ExceptionPtrSwapswaps the underlyingshared_ptrFor
operator=(nullptr_t), swapping with an emptyexception_ptrpreserves ownership semantics and allows the temporary's destructor to release the previous control block correctly.Validation
The existing
Dev11_0299014_exception_ptr_requirementstest already exercises the affected semantics, including:nullptrconstructionnullptrNo ABI-visible layout or exported CRT symbol is changed.