← Back to Pull requests

`<exception>`: Optimize `exception_ptr` operations #6403

Open
unknown opened this pull request with 227 lines diff across 2 files
View on GitHub
unknown unknown commented on Aug 15, 2026 17:55 UTC
Author

Summary

Optimizes several std::exception_ptr operations that currently call out-of-line CRT helpers even though the representation is already known in <exception>.

This change:

  • makes the default constructor and nullptr_t constructor rely on the existing null member initializers

  • implements operator bool() as _Data1 != nullptr

  • compares _Data1 directly in operator==

  • swaps _Data1 and _Data2 directly

  • implements assignment from nullptr_t using swap-with-empty, avoiding __ExceptionPtrAssign
  • The exported CRT helper functions remain unchanged for ABI compatibility.

    Fixes #6387.

    Rationale

    exception_ptr is intentionally laid out to match shared_ptr<const _EXCEPTION_RECORD>. Its two data members correspond to the shared pointer's stored pointer and control block, and the implementation already contains a static_assert enforcing matching size and alignment.

    The removed out-of-line calls currently perform operations equivalent to the inlined implementations above:

  • __ExceptionPtrCreate default-constructs an empty shared_ptr

  • __ExceptionPtrToBool converts the underlying shared_ptr to bool

  • __ExceptionPtrCompare compares the underlying shared_ptr

  • __ExceptionPtrSwap swaps the underlying shared_ptr
  • For operator=(nullptr_t), swapping with an empty exception_ptr preserves ownership semantics and allows the temporary's destructor to release the previous control block correctly.

    Validation

    The existing Dev11_0299014_exception_ptr_requirements test already exercises the affected semantics, including:

  • default and nullptr construction

  • bool conversion

  • equality between empty, aliased, and distinct exception pointers

  • assignment from nullptr

  • swapping

  • self-swap
  • No ABI-visible layout or exported CRT symbol is changed.

    Diff: 227 lines (+170 / -57) across 2 files Reviewer: YexuanXiao Review duration: 135211m
    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
    0.44
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.9% (MEDIUM) · Higher = larger blast radius
    43.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.3% · Safe to merge
    24.3%
    Repository