util: Add missing types in make_secure_unique #31464

pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2412-forward-type changing 1 files +2 −2
  1. maflcko commented at 8:50 pm on December 10, 2024: member

    The return type of std::forward depends on the template type, and can not be recovered from the args. Attempting to do so will result in a compile failure. For example, make_secure_unique<std::string>(std::string{}); does not compile on current master, but does with this pull.

    Another example would be make_secure_unique<std::pair<std::string, std::unique_ptr<int>>>(std::string{}, std::make_unique<int>(21));

  2. DrahtBot commented at 8:50 pm on December 10, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31464.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK hodlinator, hebasto, TheCharlatan

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Utils/log/libs on Dec 10, 2024
  4. maflcko added the label Refactoring on Dec 10, 2024
  5. util: Add missing types in make_secure_unique fa397177ac
  6. maflcko force-pushed on Dec 10, 2024
  7. hodlinator approved
  8. hodlinator commented at 8:25 pm on December 16, 2024: contributor

    ACK fa397177acfa1006ea6feee0b215c53e51f284de

    Accidentally tested make_secure_unique<std::string>(std::string{}) with std::forward<T> in the implementation (misremembering the change in this PR). It worked, so I came up with a better test case which requires std::forward<Args>:

    0make_secure_unique<std::pair<std::string, std::unique_ptr<int>>>(std::string{}, std::make_unique<int>(21));
    
    • T != Args
    • uses “move-only” std::unique_ptr in case it shakes out issues with l-values and our std::forward usage.

    My only nit would be changing the PR summary to an example closer to that.

  9. maflcko commented at 7:30 am on December 17, 2024: member
    thx, added your example as well to the description.
  10. hebasto approved
  11. hebasto commented at 3:41 pm on December 17, 2024: member

    ACK fa397177acfa1006ea6feee0b215c53e51f284de.

    Also: https://stackoverflow.com/a/32205061.

  12. TheCharlatan approved
  13. TheCharlatan commented at 7:39 pm on January 5, 2025: contributor
    ACK fa397177acfa1006ea6feee0b215c53e51f284de
  14. maflcko added this to the milestone 29.0 on Jan 6, 2025
  15. fanquake merged this on Jan 6, 2025
  16. fanquake closed this on Jan 6, 2025

  17. maflcko deleted the branch on Jan 10, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-01-23 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me