woboq / verdigris

Qt without moc: set of macros to use Qt without needing moc
https://woboq.com/blog/verdigris-qt-without-moc.html
GNU Lesser General Public License v3.0
638 stars 58 forks source link

Integer truncation warnings on 64-bit MSVC #78

Open nyanpasu64 opened 4 years ago

nyanpasu64 commented 4 years ago

This issue is on both verdigris master and 1.2.

In https://github.com/woboq/verdigris/blob/master/src/wobjectimpl.h, there are three occurrences of *stringLengthP++ = s.size();. On 64-bit MSVC, the first two occurrences have the following warning:

C:\Users\nyanpasu\code\exotracker\3rdparty\verdigris\wobjectimpl.h:616: warning: C4244: '=': conversion from 'QIntegerForSize<8>::Signed' to 'int', possible loss of data

Do you think it's worth inserting an explicit cast?

ogoffart commented 4 years ago

Yes, we could add cast to silence the warning.

nyanpasu64 commented 4 years ago

Forgot to mention, I'm not sure why the third occurrence has no warning, and maybe compiles even with /WX (aka -Werror) and without a cast. Might be a better idea to cast it anyway.