Malleable booleans



Summary:

In an email thread, Thomas Zander raised a concern about the inherent malleability of scripts that use booleans as inputs. Pieter Wuille had mentioned this issue earlier in the thread. Zander gave an example of assigning "2" to a native C++ bool, which results in neither true nor false hitting when checked. However, Wladimir clarified that C++ booleans are protected against this and provided code to demonstrate it. The code prints 'It is true' and also shows how `bool(something)` can be used as equivalent of x != 0.


Updated on: 2023-06-09T03:08:11.953357+00:00