Dmitry,
afair the fix is to disable the int truncation warnings in MSVC. For whatever reason they seem to enable those bogus warnings.
bye michael
On 06/28/2012 12:12 PM, Dmitry Timoshkov wrote:
Michael Stefaniuc mstefani@redhat.com wrote:
afair the fix is to disable the int truncation warnings in MSVC. For whatever reason they seem to enable those bogus warnings.
The warnings are not bogus, the PSDK compiler also emits a warning when truncating from double to float while gcc keeps silence for instance. Anyway, the patch shouldn't hurt, PSDK headers have similar casts. This patch also helps to pay more attention to warnings: when there are lots of existing ones, it's hard to recognize new and possibly real problems in the code.
On 06/28/2012 01:00 PM, Dmitry Timoshkov wrote:
They are bogus as the C standard explicitly allows conversion between integer types.
truncating from double to float while gcc keeps silence for instance.
I never looked at that but I assume the same holds true as above.
Anyway, the patch shouldn't hurt, PSDK headers have similar casts. This
In this specific case it doesn't. Start littering the code with casts to get rid of all those warnings and it will majorly hurt. Unneeded casts are *BAD*; worse then ignoring bogus warnings from a compiler.
bye michael
Michael Stefaniuc mstefani@redhat.com wrote:
truncating from double to float while gcc keeps silence for instance.
I never looked at that but I assume the same holds true as above.
The following thread has some interesting details: http://www.daniweb.com/software-development/c/threads/114052/warning-c4305-t...
Obviosuly I'm not planning to add the casts everywhere, but the inline constructs which specifically targeting the pointer to integer conversions that imply truncation should compile without warnings IMHO.
On 06/28/2012 01:50 PM, Dmitry Timoshkov wrote:
WOW, that's pretty stupid. "0.1" has no type, it is a numeric literal. Type is inferred from the context and only if that isn't possible it will fall back to the intrinsic type. You can even say "int i = 0.1;" and that is correct C.
gcc -Wall -Wextra does not complain about the examples in the thread you quoted as that is the correct C behavior. MSVC is a C++ compiler beaten into submission to do C. And C++ perverted C.
bye michael
Am Donnerstag, 28. Juni 2012, 20:50:15 schrieb Dmitry Timoshkov:
Fwiw, I fixed a number of double-to-float conversion warnings in MSVC in wined3d, d3d8 and d3d9 a while ago, as well as some similar integer issues. I fixed most of those warnings by using the proper data types and explicitly using float literals. I added a handful of casts in places where the API differences forced me to(d3d vs GL clipplanes if I remember correctly).
From my experience with wined3d the majority warnings(~90 %) from msvc made
sense and pointed out potential bugs in the code. The rest were cases like the one Dmitry wants to patch where the API definitions force a conversion with potential data loss.