Live data from Hacker News

Truthiness in C

dxuuu.xyz

21–26 of 26 posts

Re: Truthiness in C

#21
post #19

Earlier quoted context omitted.

Did you mean `typedef int bool`?

No, _Bool is a distinct type, introduced by the 1999 edition of the standard.

No, marcosdumay wrote 'typedef bool int', by which he/she probably meant 'typedef int bool', which was not so uncommon when there was no native bool type in C, since the former would be illegal since the standard forbids typedefing already existent types such as int. strkitten informed about the probable typo.

Re: Truthiness in C

#24
This misses the fact that signed integer promotions are generally not free because they require sign extension. For example, the cast in b() emits a `movsx` (move with sign-extension). `movsx` is not free in the ways that `mov` can be.

`mov` can be "free" in two ways:

- the compiler can frequently avoid emitting the `mov` when part of a larger operation

- modern CPUs handle `mov` instructions earlier in the pipeline

Neither of those are true for `movsx`.

Re: Truthiness in C

#25
post #19

Earlier quoted context omitted.

No, _Bool is a distinct type, introduced by the 1999 edition of the standard.

No, marcosdumay wrote 'typedef bool int', by which he/she probably meant 'typedef int bool', which was not so uncommon when there was no native bool type in C, since the former would be illegal since the standard forbids typedefing already existent types such as int. strkitten informed about the probable typo.

Sorry, I managed to miss the context.
Post reply on HN