------- Comment #3 from manu at gcc dot gnu dot org 2010-02-24 10:23 ------- (In reply to comment #2) > It would be nice to have the warning in the second case too, i.e. for > (unsigned long long)(val1*val2).
Actually, it is a bit weird that the operands are not promoted to unsigned long long. Normally, I would say that if you do an explicit cast, then we have to assume that you know what you are doing. However, in this case, the result is totally unexpected, so I think we could warn. Also for (double) (int * int) versus ((double) int * int). This is another subtle case. I think this is an interesting warning. > Another solution, probably a lot more complex to implement, is to have > a compilation switch to expand all calculus to 64 bits even when "int" > is 32 bits, and let the optimiser convert back to simpler assembly code > when the result used is only 32 bits. That is independent of this warning. If you want that, open a new PR and see what others say. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42935