lkml.org 
[lkml]   [2006]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 1/1] consolidate TRUE and FALSE
Xavier Bestel <xavier.bestel@free.fr> wrote:
>
> On Thu, 16 Mar 2006 13:26:39 -0800
> Andrew Morton <akpm@osdl.org> wrote:
>
> > C99 does have boolean support, so the proper thing to do is to start
> > using it - implement stdbool.h, fix up fallout, start fixing subsystems.
> > Given that, and as Greg has fixed up this particular build error I'll drop
> > the patch.
>
> Isn't there a runtime cost converting all "non-false" values to a unique "true" (i.e. converting non-zero values to one) ?

Yes, there will be. If people do wrong things.

> I mean:
>
> bool res = strcmp(string, "whatever");
> if(res)
> something_else();

There's an implicit conversion from integer (-1, 0, 1) to boolean there.
It _should_ require a typecast or, better,

bool res = (strcmp(...) != 0);

But it won't require that - the compiler will just accept it.. A new `gcc
--implement-bools-properly' or perhaps sparse should warn about the above.

(Hopefully the compiler would have the brains to optimise it all away in
this specific example).

But yeah, it's always possible to deoptimise your code.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-03-18 00:00    [W:0.158 / U:0.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site