Fix non-const shared_ptr callback deprecation warnings with GCC #3450
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 529 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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
Diff Size
diff_size
0.375
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3450"
general
weight: 0.35
mini-1235
Description
Subscription callbacks taking a
std::shared_ptrto a non-const message were deprecated in #2975 (Lyrical), but the[[deprecated]]function,AnySubscriptionCallback::set_deprecated(), is only used inside rclcpp headers. Downstream packages include these as system headers, and GCC does not show warnings located in system headers, even if user code triggered the template instantiation, so only Clang >= 18 shows the warning.Instead, add
[[deprecated]]overloads ofcreate_subscription()andcreate_generic_subscription()(free functions andNodeandLifecycleNodemember functions), constrained to the deprecated callback signatures, so that the warning is located at the user's call. Then removeset_deprecated()and theRCLCPP_AVOID_DEPRECATIONS_FOR_UNIT_TESTSmacro.Since GCC users will only see the warning starting with Makoa, add TODOs to remove these overloads and the support for these callback signatures after Makoa.
Part of #3176
Is this user-facing behavior change?
Yes: with GCC, subscription callbacks taking a
std::shared_ptr<MessageT>(e.g.,MessageT::SharedPtr) now trigger a deprecation warning at thecreate_subscription()orcreate_generic_subscription()call. Usestd::shared_ptr<const MessageT>(e.g.,MessageT::ConstSharedPtr) instead. With Clang, the warning is now also located at that call, but it is shown twice for theNodeandLifecycleNodemember functions (once for the function template and once for its specialization).<details><summary>Example with GCC 15</summary>
</details>
Calling
AnySubscriptionCallback::set()directly with a deprecated callback no longer triggers a warning (it previously did only with Clang).Did you use Generative AI?
Claude Opus 5.5 to find out why the warning was not shown with GCC and to implement this fix.
Additional Information
This came up in #3449, which removes these callbacks and should now wait until after Makoa. With this, GCC shows the warning in ros-tooling/topic_tools, which ros-tooling/topic_tools#159 fixes.