Align struct COrphan definition #9269

pull sipa wants to merge 1 commits into bitcoin:master from sipa:oneorphan changing 2 files +2 −0
  1. sipa commented at 3:29 AM on December 3, 2016: member

    Since #8179 the struct COrphan definition gained an extra field. The mirrored definition in DoS_tests was not updated, however. This violates the C++ one definition rule.

    Found using GCC 6.2.0, when compiling with -flto:

    test/DoS_tests.cpp:29:8: warning: type 'struct COrphanTx' violates the C++ One Definition Rule [-Wodr]
     struct COrphanTx {
            ^
    net_processing.cpp:52:8: note: a different type is defined in another translation unit
     struct COrphanTx {
            ^
    net_processing.cpp:55:13: note: the first difference of corresponding definitions is field 'nTimeExpire'
         int64_t nTimeExpire;
                 ^
    net_processing.cpp:52:8: note: a type with different number of fields is defined in another translation unit
     struct COrphanTx {
            ^
    test/DoS_tests.cpp:29:8: note: type 'struct COrphanTx' itself violate the C++ One Definition Rule
     struct COrphanTx {
            ^
    net_processing.cpp:52:8: note: the incompatible type is defined here
     struct COrphanTx {
            ^
    
  2. sipa added the label Bug on Dec 3, 2016
  3. dcousens commented at 4:35 AM on December 3, 2016: contributor

    No way to test ?

  4. sipa commented at 4:50 AM on December 3, 2016: member

    I believe in practice it never matters, as the added field is in the last place, and the size of COrphan isn't used. However, it is technically undefined behaviour I think.

  5. MarcoFalke commented at 1:42 PM on December 3, 2016: member

    utACK 22970b0537c9b1747ab66760b8d528fb32848262

  6. paveljanik commented at 5:38 PM on December 3, 2016: contributor

    ACK 22970b0

    Minor nit: change the comment: COrphan -> COrphanTx.

    Looks like main is still not dead: https://github.com/bitcoin/bitcoin/pull/9269/commits/22970b0537c9b1747ab66760b8d528fb32848262#diff-eb50db371aa7bd12e62a13879bc661f7L25

    ;-)

  7. gmaxwell commented at 6:57 PM on December 4, 2016: contributor

    nit: Maybe add a comment to the main definition to remind people to update this one? (ugly but...)

    utACK.

  8. sipa commented at 11:11 PM on December 4, 2016: member

    Alternatively, we could just expose these functions from main.h, and not duplicate them at all...

  9. TheBlueMatt commented at 2:01 AM on December 5, 2016: member

    Would prefer to not expose them from net_processing.h, even if duplicating them is really gross. Would prefer to add a comment instead.

  10. Align struct COrphan definition 2efc43874c
  11. sipa force-pushed on Dec 5, 2016
  12. sipa commented at 8:35 AM on December 5, 2016: member

    Added a comment.

  13. laanwj commented at 10:08 AM on December 5, 2016: member

    Adding fields to the end is harmless, a lot of software relies on that with ABIs.

    But it makes sense to sync it anyhow, ACK

  14. laanwj merged this on Dec 5, 2016
  15. laanwj closed this on Dec 5, 2016

  16. laanwj referenced this in commit 43e8150ef6 on Dec 5, 2016
  17. codablock referenced this in commit 307ac9def0 on Jan 16, 2018
  18. codablock referenced this in commit ea8920b0cb on Jan 16, 2018
  19. codablock referenced this in commit 9782c18312 on Jan 17, 2018
  20. andvgal referenced this in commit 76eefef3a2 on Jan 6, 2019
  21. CryptoCentric referenced this in commit 4dfe89635f on Feb 25, 2019
  22. DrahtBot 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-04-19 09:15 UTC

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