doc: Add switch on enum example to developer notes #17134

pull hebasto wants to merge 2 commits into bitcoin:master from hebasto:20191014-enum-doc changing 2 files +29 −1
  1. hebasto commented at 12:59 PM on October 14, 2019: member

    This PR documents a recurring issue:

  2. util: Add AllowShortCaseLabelsOnASingleLine option 11e3d5eb1d
  3. doc: Add switch on enum example c8961c7d9f
  4. fanquake added the label Docs on Oct 14, 2019
  5. in doc/developer-notes.md:591 in c8961c7d9f
     586 | +    } // no default case, so the compiler can warn about missing cases
     587 | +    assert(false);
     588 | +}
     589 | +```
     590 | +
     591 | +*Rationale*: The comment documents skipping `default:` label, and it complies with `clang-format` rules. The assertion prevents firing of `-Wreturn-type` warning on some compilers.
    


    MarcoFalke commented at 1:09 PM on October 14, 2019:

    The warning is not wrong, though. While it is not undefined behavior to cast any int to an enum class type and pass it around (where it eventually will hit the assert), it seems the right thing to do for sanity.

  6. MarcoFalke commented at 1:09 PM on October 14, 2019: member

    ACK

  7. promag commented at 2:24 PM on October 14, 2019: member

    ACK c8961c7d9fed07190628cf01f9dfad971a942b99, no excuse now, thanks!

  8. laanwj commented at 2:26 PM on October 14, 2019: member

    Seems like good advice to me. ACK c8961c7d9fed07190628cf01f9dfad971a942b99

  9. practicalswift commented at 8:42 PM on October 14, 2019: contributor

    ACK c8961c7d9fed07190628cf01f9dfad971a942b99

  10. fanquake referenced this in commit dcc640811c on Oct 14, 2019
  11. fanquake merged this on Oct 14, 2019
  12. fanquake closed this on Oct 14, 2019

  13. hebasto deleted the branch on Oct 14, 2019
  14. fanquake referenced this in commit eb292af309 on Oct 15, 2019
  15. DrahtBot locked this on Feb 15, 2022

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-16 18:14 UTC

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