Hi Manuel,
in a nutshell, what is happening is that a difference of two pointers is
assigned to an unsigned variable. First blush, the warning seems to me a
bit overzealous, but if we concur that this is what we *really* want for
4.3, we can change the affected (very old, indeed) lines of code, no
problem at all.
Hi Paolo,
Wconversion is supposed to warn for conversions that may change a
value. Can the resulting value change when converted to unsigned? If
so, the warning is warranted (I think).
Anyhow, Wconversion needs fine-tuning and I prefer for it to be useful
rather than to literally follow its definition, so if this operation
is quite frequent and safe, I could detect it and avoid the warning.
I am no GCC or C++ expert, so please give me more information on the
issue and feedback from others would be appreciated.
Well, just have a look to Gerald' examples: it's old HP / SGI STL code,
we are assigning / initializing a size_t from a pointer difference, or
arithmetic, more generally. There are quite a few instances of the
issue, beyond that pointed out by Gerald. Certainly, the HP / SGI
engineers considered those assignment harmless, and I respect that kind
of assessment, but on the other hand, at the time the compilers were
probably weaker at warning, I'm not sure. All in all, I think we can
definitely add casts to the library, would be only a few tens of lines
worth of patch, I think. Whether the warning is useful to the entire GCC
community, I cannot say... But I hope we can resolve the issue rather
quickly, because, in case, I'd like to start the audit of the library as
soon as possible and be done with the issue as far as we are concerned...
Thanks,
Paolo.
PS: well, the issue reminds me the hyper-super-long-standing issue that
pragma system headers doesn't suppress warnings from templates: as we
can see, this behavior can be really annoying... probably also very hard
to change, if I remember correctly... ;-/