[TUHS] C question for the historians

Chet Ramey chet.ramey at case.edu
Thu Nov 9 11:41:51 AEST 2017


On 11/8/17 8:22 PM, Ralph Corderoy wrote:
> Hi Chet,
> 
>>> But this w & MASK discussion is one of the weirder ones.
>>
>> gcc warns about it in its default mode
> 
> I'm having trouble triggering that, though often these things crop up
> when you don't want them, not when you do.
> 
>     $ cat t.c
>     #define M 0xa5
> 
>     int foo(int i, int j)
>     {
> 	if (i & M && j & ~M)
> 	    return 42;
> 	return -314;
>     }
>     $ gcc -Wall -pedantic`: swine` -O3 -c t.c
>     $
> 
> When it does moan, is it one of those things where just extra
> parenthesis suffice as a signal that you meant it?

Yeah, that's what I thought, but I didn't go so far as to test it.

(There's also the annoying warning on `if (x = something)'; maybe that's
what I was thinking.)

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet at case.edu    http://cnswww.cns.cwru.edu/~chet/


More information about the TUHS mailing list