John Temples wrote: > On Wed, 4 Jul 2007, John Dammeyer wrote: > >> Why force the compiler to create 16 bit compares for a test against index >> bounds that fit in 8 bits? After all, that's what integer promotion >> would do. > > No, it isn't. The C standard does not require two eight-bit objects > to be promoted to 16 bits when they're compared. Only a broken > implementation would do that. Exactly. Integer promotion only affects operations on 8-bit values, not every use of them. And any decent compiler would not promote values which would get truncated anyway. For example, integer promotion shouldn't have an effect on this code: char a; char b = 15; a = b+1; Here, b could get promoted, but a decent compiler wouldn't do that, since it is getting assigned to a anyway, which is 8 bits wide. Here's a case where it WOULD matter: char a = 0xFF; char b = a+1; if((a+1) == b) Here, a is promoted. a+1 = 0x100 which is NOT equal to b (which is 0x00). If you don't want it to get promoted (i.e. you want the special truncating behavior, which is unintuitive of course and therefore rightly not the default), just cast it to a char or use &0xFF (which, again, any decent compiler should interpret as a cast and avoid all overhead). -- Hector Martin (hector@marcansoft.com) Public Key: http://www.marcansoft.com/marcan.asc -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist