Messages in this thread |  | | From | "Peter T. Breuer" <> | Subject | Re: [IDEA+RFC] Possible solution for min()/max() war | Date | Fri, 7 Sep 2001 17:17:17 +0200 (CEST) |
| |
"Bill Pringlemeir wrote:" > compile_time_assert( (_x - 1 > 0 && _y - 1 > 0) \ > || (_x - 1 < 0 && _y - 1 < 0)); \ > > This should prevent all cases where the __MIN(x,y) macro can screw up > due to sign issues (on that machine). If you do this, the `sizeof'
Eh? "0" is a signed integer constant. So your comparisons force promotion to int when x is smaller size. I'm not sure what type
"unsigned foo - signed int"
would have either! It seems to me that you are making things very murky, which is precisely what you want to avoid.
> check isn't needed. A MIN(int, long) etc should probably be ok. The > only caveats are the promotion in the __MIN itself create a sign > mismatch. > > However, if the `sizeof' check remains, then you don't have to worry > about this and both versions are equivalent. Some other things to > worry about is what if the type is already const? Maybe that works...
No parsum.
> What if you try `MIN(x,_x);'. I think that this is something that > David took care of in the "3 arg min".
You can't take care of it. A macro is always vulnerable to name clashes.
Peter - 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/
|  |