Skip to content

std::make_shared calls are now [[nodiscard]] in MSVC and cause build warnings #961

@brawner

Description

@brawner

Bug report

Required Info:

  • Operating System:
    • Windows 10
  • Installation type:
    • Source install, MSVC 2019, 16,24
  • Version or commit hash:
    • master

Issue

std::make_shared is now annotated as [[nodiscard]] on Windows MSVC 2019 and will cause MSBuild warnings. I can't tell if that's part of the STL spec, or if this is something that MS has decided to do.

This was noticed on the citest farm instance I'm running in a docker container. It installs the most recent VS BuildTools which may be ahead of the ci.ros2.org version.

This affects test_node.cpp and test_parameter_client.cpp
https://github.com/ros2/rclcpp/blob/master/rclcpp/test/test_node.cpp
https://github.com/ros2/rclcpp/blob/master/rclcpp/test/test_parameter_client.cpp

If desired, I can create a corresponding PR. Wrapping the make shared call in an EXPECT_TRUE(make_shared() != nullptr) statement would probably resolve the issue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions