[xsd-users] -Wconversion warnings

Benjamin Schindler bschindler at inf.ethz.ch
Thu Dec 16 05:57:52 EST 2010


Hi Boris

Actually, we quickly backed away from enabling this warning as it would
be too much work to really make it work.
There are some useful cases, but most of them are just noise. So I'd
suggest you don't waste too much time on it.
The pragma does sound like a good solution though!

Cheers
Benjamin

On 12/16/2010 09:50 AM, Boris Kolpackov wrote:
> Hi Benjamin,
> 
> Benjamin Schindler <bschindler at inf.ethz.ch> writes:
> 
>> We just turned on -Wconversion warnings in our xsd-using project and it
>> generated a huge numbers of warnings from libxsd, but they are all at
>> the same place. Could they be fixed please?
>>
>> libxsd/xsd/cxx/tree/date-time-ostream.txx:31:13: warning: conversion to
>> ‘short int’ from ‘int’ may alter its value
> 
> Here is the line that this error points to:
> 
> h = -h;
> 
> The 'h' variable is declared as short. I am not sure I would like to
> "fix" this since it will just make the code uglier and less readable.
> All other places are very similar. Plus, if you turn -Wsign-conversion,
> you get a lot more of these warnings.
> 
> Don't you also get a lot of such warnings from other libraries that
> you use? For example, I get quite a few from the Xerces-C++ headers.
> 
> I think the best option, at least for XSD, would be to disable these
> warnings for the generated/libxsd code, as Balasubramanyam suggested.
> Unfortunately, GCC does not provide the necessary mechanism until
> version 4.6 (not yet released; adds #pragma GCC diagnostic push/pop).
> We can cleanly disable the warnings starting from this version but
> I am not sure whether this will help you.
> 
> The only other option that I can think of is to install XSD into
> a separate directory and use the -isystem option instead of -I
> to specify the libxsd include directory. This will make GCC treat
> the libxsd headers as system headers and suppress all the warnings
> in them.
> 
> Boris



More information about the xsd-users mailing list