What is Nostr?
Wladimir [ARCHIVE] /
npub1xqsโ€ฆmc2p
2023-06-07 15:26:28

Wladimir [ARCHIVE] on Nostr: ๐Ÿ“… Original date posted:2014-10-14 ๐Ÿ“ Original message:On Tue, Oct 14, 2014 at ...

๐Ÿ“… Original date posted:2014-10-14
๐Ÿ“ Original message:On Tue, Oct 14, 2014 at 9:27 AM, Thomas Zander <thomas at thomaszander.se> wrote:
> On Tuesday 14. October 2014 04.34.16 Pieter Wuille wrote:
>> This means that scripts that use booleans as inputs will be inherently
>> malleable.
>
> I've ran into this issue in C++ often enough,
> a funny example is assigning "2" to a native c++ bool and then you can do a
> if (myBool == true)
> else if (myBool == false)
> and neither of them will hit.

Off topic nit: I think you're confused with custom BOOL typedefs in C?
C++ booleans are protected against this (C++ standard ยง4.7/4 according
to Google).:

```
#include <stdio.h>

int main()
{
bool myBool;
myBool = 2;
if (myBool == true)
printf("It is true!\n");
else if (myBool == false)
printf("It is false!\n");
else
printf("It is something else!\n");
}
```

Prints 'It is true'. You can also use bool(something) as equivalent of
`x != 0`; as in `assert(bool(2) == true);`.

Wladimir
Author Public Key
npub1xqshkqv2g7uea4xzqwvmgjcz7u8vfavw6aazs999v0azsv3w7u3qpymc2p