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

General: Add nodiscard attribute to create* API #409

Merged
merged 1 commit into from
Apr 2, 2024
Merged

Conversation

stotko
Copy link
Owner

@stotko stotko commented Apr 2, 2024

The create* API returns the newly constructed and initialized object that can then be used. However, ignoring the return value will result in loosing access to that object and thus will lead not only to a likely crash but also to a memory leak. Add the [[nodiscard]] attribute to these functions to better warn users of this issue and indicate the correct usage of these functions.

@stotko stotko added this to the 2.0.0 milestone Apr 2, 2024
Copy link

codecov bot commented Apr 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.33%. Comparing base (1f0b2d5) to head (64574c9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #409   +/-   ##
=======================================
  Coverage   97.33%   97.33%           
=======================================
  Files          31       31           
  Lines        2512     2512           
=======================================
  Hits         2445     2445           
  Misses         67       67           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stotko stotko merged commit ac5b1f7 into master Apr 2, 2024
61 checks passed
@stotko stotko deleted the nodiscard branch April 2, 2024 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant