> I'm looking at cleaning up a few compile nits and I'm wondering what the > officially approved way of silencing "may not be used" warnings: > > int > foo(int flag) > { > int j; > > if (flag) > j = 1; > > /* > * This noop statement is enough to confuse the optimiser so it > * forgets that j is initialised iff flag != 0 > */ > flag = !!flag;
I don't know about the "official" way to silence the compiler (a well placed else statement or a "default" switch case usually does the trick for me) That is to say, I'm willing to argue that fixing the flow of control is the only clean way of getting rid of these warnings, unless you know something special about the allowed values of the offending variable (eg. you know that your switch case is exhaustive), in which case a dummy "default" or initializer cannot hurt you much. Also !!x IS NOT a noop. For example, !!5 == 1. I think you meant to say `flag = ~~flag', which indeed is a NOP. Pat. To Unsubscribe: send mail to majord...@freebsd.org with "unsubscribe freebsd-hackers" in the body of the message