Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
brawner opened this issue Jan 8, 2020 · 4 comments
Assignees

Comments

@brawner
Copy link
Contributor

brawner commented Jan 8, 2020

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.

@dirk-thomas
Copy link
Member

A pull request would be appreciated. I would suggest to simply assign the returned value to a local variable.

@Karsten1987
Copy link
Contributor

FWIW, you might have to (void) that local variable then in order to avoid compiler warnings -Wunused.

@brawner
Copy link
Contributor Author

brawner commented Jan 13, 2020

@dirk-thomas PR opened for this issue

@wjwwood
Copy link
Member

wjwwood commented Jan 22, 2020

Closing as #963 was merged.

@wjwwood wjwwood closed this as completed Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants