Hi, I decided to move from gcc to clang compilation, as it's easier to compile and it uses a lot of new features gcc doesn't have yet officially (like for example the address/undefined/thread sanitizer or more c++11 features).
I compiled the v2 branch with the same options + c99 standard + pedantic and I got these results in the attached file.
Thanks. None of these look particularly serious but they should probably be fixed at some point.
I'm sure the "'GameMission_t' -> 'GameMode_t'", the "memset" and the "MF_SPECTRAL" are issues to be concerned if some assumptions are wrongly done.
Apart from that, I recompiled everything with the ub sanitizer, which instruments the code in order to report runtime undefined behaviors. I was surprised to see the result when I ran chocolate-doom with doom v1.9 shareware version and let the game play all the demos... it's in the new attached file. How could doom work with these ub things?
The ub warnings don't actually seem that big an issue. Undefined behaviors are just things that aren't explicitly specified by the C standard, but some behaviors are so common across all compilers and CPUs that they can be reasonably assumed. Left shift of a negative value is one example. The C standard says:
"The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. If E1 has an unsigned type, the value of the result is E1|2E2, reduced modulo one more than the maximum value representable in the result type. If E1 has a signed type and nonnegative value, and E1|2E2 is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined."
In practise though, all modern CPUs do the sensible thing. Integer overflows are another similar example.
Ping. Someone at doomworld noted a buffer overflow, which is a lot similar to the memset warnings I got with clang. Uploading a list of the relevant warnings in the v2 branch.
Attached the 'memset' fix from prboom+ code. I don't understand why prboom uses '&mousearray' as the pointer, instead of 'mousearray', which is a pointer...
Last edit: Edward-san 2013-09-18