|Title||The MPS does not build with gcc -Wconversion|
|Assigned user||Gareth Rees|
|Description||Lots of projects have -Wconversion in their compilation options, for example . But the MPS does not compile under gcc with this option. (See job003757 for the corresponding issue with respect to clang.)|
|Analysis||The MPS is very clean as regards implicit integer conversions. The main problem encountered was bitfields. To convince GCC that there will be no data loss when assigning to a bitfield, you have to write:|
struct.field = ((type)value & (type)mask);
I encapsulated this in a macro in misc.h:
#define BITFIELD(type, value, width) ((type)value & (((type)1 << (width)) - 1))
and then revised setter macros SegSetPM, SegSetDepth and so on to use it.
The other problem is that the event system uses the type int : 1 for Boolean bitfields. Because int is signed, the values of this type are 0 and -1, and so you can't assign TRUE to this bitfield (even using the BITFIELD macro) without getting a warning about the sign conversion. So I changed the type of these bitfields to unsigned : 1.
|Created by||Gareth Rees|
|Created on||2014-04-11 14:24:20|
|Last modified by||Gareth Rees|
|Last modified on||2014-04-14 21:50:22|
|History||2014-04-11 GDR Created.|
|185467||open||2014-04-11 15:28:03||Gareth Rees||Turn -Wconversion off again. (The MPS builds with this option with gcc 4.8 but not with gcc 4.6.3 on the Travis buildbots.)|
|185463||open||2014-04-11 14:25:15||Gareth Rees||Add -Wconversion to the options for GCC. Ensure that the MPS builds.|
|185459||open||2014-04-11 12:17:39||Gareth Rees||Not ready for gcc -Wconversion.|
|185457||open||2014-04-11 12:06:28||Gareth Rees||Add -Wconversion to options for GCC and Clang.
Ensure that the MPS builds with this option with Clang.