Explicitly initialize prevector _union #14028

pull Empact wants to merge 1 commits into bitcoin:master from Empact:prevector-explicit-initialization changing 1 files +5 −5
  1. Empact commented at 9:24 AM on August 23, 2018: member

    No description provided.

  2. Empact commented at 9:24 AM on August 23, 2018: member

    Prompted by #13902

  3. fanquake added the label Refactoring on Aug 23, 2018
  4. Empact cross-referenced this on Aug 23, 2018 from issue prevector: Suppress two -Wmaybe-uninitialized (gcc) warnings in indirect_ptr(...) by practicalswift
  5. Empact force-pushed on Aug 23, 2018
  6. Empact force-pushed on Aug 23, 2018
  7. in src/prevector.h:175 in bfa1d038f1 outdated
     174 | +            indirect.indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * _size));
     175 | +            assert(indirect.indirect);
     176 | +            indirect.capacity = _size;
     177 | +            _size += N + 1;
     178 | +            return indirect;
     179 | +        }
    


  8. DrahtBot cross-referenced this on Aug 23, 2018 from issue Remove ambiguity in construction of prevector by Empact
  9. DrahtBot commented at 11:29 AM on August 23, 2018: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->No more conflicts as of last run.

  10. in src/prevector.h:267 in bfa1d038f1 outdated
     263 | @@ -248,32 +264,24 @@ class prevector {
     264 |  
     265 |      prevector() : _size(0), _union{{}} {}
     266 |  
     267 | -    explicit prevector(size_type n) : _size(0) {
     268 | -        resize(n);
     269 | +    explicit prevector(size_type n) : _size(n), _union{init_union()} {
    


    sipa commented at 4:15 PM on August 23, 2018:

    This is wrong. The _size field does not directly encode the size (see the comments above the class).


    Empact commented at 4:50 PM on August 23, 2018:

    init_union adds the N + 1 when appropriate.


    sipa commented at 4:55 PM on August 23, 2018:

    Yuck.


    Empact commented at 5:15 PM on August 23, 2018:

    Fair enough, moved it out of the initializer.

  11. Empact force-pushed on Aug 23, 2018
  12. Empact force-pushed on Aug 23, 2018
  13. Empact force-pushed on Aug 23, 2018
  14. Empact force-pushed on Aug 23, 2018
  15. practicalswift commented at 5:48 PM on August 23, 2018: contributor

    Concept ACK

    This fixes the compiler warning described in #13902

  16. Empact force-pushed on Aug 24, 2018
  17. Empact force-pushed on Aug 24, 2018
  18. Empact commented at 8:53 AM on August 24, 2018: member

    Pared the PR down to just explicitly initializing the _union

  19. practicalswift commented at 9:14 AM on August 24, 2018: contributor

    The updated version still fixes the compiler warning.

    ACK f955a50384ad53e6d1e89f373905ea8dabc46e93

  20. DrahtBot added the label Needs rebase on Aug 27, 2018
  21. Explicitly initialize prevector _union 1d9aa008d6
  22. Empact force-pushed on Aug 27, 2018
  23. Empact commented at 4:51 PM on August 27, 2018: member

    Rebased for #14030

  24. practicalswift commented at 4:57 PM on August 27, 2018: contributor

    utACK 1d9aa008d6e043c29c3c5b030a6d04278aea233b

  25. ken2812221 commented at 5:00 PM on August 27, 2018: contributor

    utACK 1d9aa008d6e043c29c3c5b030a6d04278aea233b

  26. DrahtBot removed the label Needs rebase on Aug 27, 2018
  27. laanwj merged this on Aug 29, 2018
  28. laanwj closed this on Aug 29, 2018

  29. laanwj referenced this in commit b0eb8f7ed4 on Aug 29, 2018
  30. Bushstar cross-referenced this on Sep 4, 2018 from issue commits from bitcoin/master by Bushstar
  31. Empact cross-referenced this on Sep 19, 2018 from issue refactor: Lift prevector default vals to the member declaration by Empact
  32. Empact deleted the branch on Oct 9, 2018
  33. cmihai cross-referenced this on May 2, 2019 from issue Fix GCC warnings in prevector.h by initializing class fields by cmihai
  34. MarcoFalke referenced this in commit 3632143ebb on May 6, 2019
  35. sidhujag referenced this in commit e97c1bc114 on May 7, 2019
  36. sickpig cross-referenced this on Mar 2, 2020 from issue [port] update prevector.h by sickpig
  37. random-zebra cross-referenced this on Apr 24, 2020 from issue [Core] Prevector by random-zebra
  38. Fuzzbawls referenced this in commit 8dfc4806f7 on May 19, 2020
  39. PastaPastaPasta referenced this in commit 8dc8d9c32e on Jun 27, 2021
  40. PastaPastaPasta referenced this in commit 3325df2cc1 on Jun 27, 2021
  41. PastaPastaPasta referenced this in commit afe9198916 on Jun 28, 2021
  42. PastaPastaPasta referenced this in commit cdbf7957d2 on Jun 28, 2021
  43. PastaPastaPasta referenced this in commit b480328fd0 on Jun 29, 2021
  44. PastaPastaPasta referenced this in commit 612b7e8fab on Jun 29, 2021
  45. PastaPastaPasta referenced this in commit 431ef8f783 on Jun 29, 2021
  46. PastaPastaPasta referenced this in commit aca3eb1b40 on Jun 29, 2021
  47. PastaPastaPasta referenced this in commit c62f8f6ef0 on Jun 29, 2021
  48. PastaPastaPasta referenced this in commit 493e0e8769 on Jun 29, 2021
  49. Munkybooty referenced this in commit 1cbd42663e on Jun 30, 2021
  50. PastaPastaPasta referenced this in commit 2d91eb7b77 on Jul 1, 2021
  51. PastaPastaPasta referenced this in commit 90f2117558 on Jul 1, 2021
  52. PastaPastaPasta referenced this in commit 7b1d8c5e53 on Jul 1, 2021
  53. PastaPastaPasta referenced this in commit bb27dde3cc on Jul 8, 2021
  54. PastaPastaPasta referenced this in commit 698ca44c98 on Jul 10, 2021
  55. bitcoin locked this on Sep 8, 2021

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: 2026-05-20 06:54 UTC