On 07/02/2016 02:28 PM, Uwe Stöhr wrote: > Am 02.07.2016 um 20:15 schrieb Richard Heck: > >> All harmless. >> >> In future, you can fix these sorts of warnings easily. > > I understand the compiler warnings but it is not easy for me to decide > if a truncation of values was intended or not. I mean if it is > intended one should use int(). Since this is not done, I must assume > that this was not intended.
This sort of thing is known as an "implicit conversion". It happens all the time. For example, consider the following: Type * type_ptr; .... if (type_ptr) { ...do something... } This involves an implicit conversion from Type* to a bool. You get the warning in the case of a conversion from double to int because, as it says, there /could/ be a loss of data. But such conversions are still quite common. > >> int const y_bar = deleted() ? y - fm.maxAscent() / 3 >> : y + 2 * pi.base.solidLineOffset() + >> pi.base.solidLineThickness(); >> >> Here, we clearly do want to do that, since the function to which >> we're about to >> pass y_bar wants an int, too. > > That is not clear to me. How can I know that we want to floor the > result of a division. Do we really want to get 2 if fm.maxAscent() is > either 6, 7 or 8? That is quite strange to me. Another question arises > if we want the truncation: why do we divide by 3 not e.g. 4? Well, there's a comment just above: // Calculate 1/3 height of font Granted, one might have used rounding here. But, so far as I am aware, no bug has been reported about the drawing of change markers. And adding int(...) does not change behavior. > That is why I report the warnings uncommented. It might be that it is > obvious for others but for me they are not. As I said, you just have to read the code. If you don't understand it, or can't figure out what's intended, then that would be the right time to report the warning. Richard