From: Wladimir <laanwj@gmail.com>
To: Thomas Zander <thomas@thomaszander.se>
Cc: Bitcoin Dev <bitcoin-development@lists.sourceforge.net>
Subject: Re: [Bitcoin-development] Malleable booleans
Date: Tue, 14 Oct 2014 10:04:20 +0200 [thread overview]
Message-ID: <CA+s+GJBvOH9cW_yaK7ZEDUYznDe=KeoMYMZ3KF=P503JceWFeg@mail.gmail.com> (raw)
In-Reply-To: <201410140927.36252.thomas@thomaszander.se>
On Tue, Oct 14, 2014 at 9:27 AM, Thomas Zander <thomas@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
next prev parent reply other threads:[~2014-10-14 8:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-14 2:34 [Bitcoin-development] Malleable booleans Pieter Wuille
2014-10-14 2:45 ` Gregory Maxwell
2014-10-14 7:27 ` Thomas Zander
2014-10-14 7:52 ` Gregory Maxwell
2014-10-14 8:04 ` Wladimir [this message]
2014-10-14 8:09 ` Peter Todd
2014-10-14 18:54 ` Pieter Wuille
2014-10-14 19:45 ` Peter Todd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+s+GJBvOH9cW_yaK7ZEDUYznDe=KeoMYMZ3KF=P503JceWFeg@mail.gmail.com' \
--to=laanwj@gmail.com \
--cc=bitcoin-development@lists.sourceforge.net \
--cc=thomas@thomaszander.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox