PCRE2Project / pcre2

PCRE2 development is now based here.
Other
885 stars 185 forks source link

Loss of data warnings on Visual Studio #384

Closed csware closed 7 months ago

csware commented 7 months ago

With the latest 10.43 version Microsoft VisualStudio reports several possibel loss of precisions on x64 build (compiled with /W3):

...
 pcre2_compile.c
C:\projects\tortoisegit-06nst\ext\pcre2\src\pcre2_compile.c(7552,58): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data [C:\projects\tortoisegit-06nst\ext\build\pcre2.vcxproj]
C:\projects\tortoisegit-06nst\ext\pcre2\src\pcre2_compile.c(7602,57): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data [C:\projects\tortoisegit-06nst\ext\build\pcre2.vcxproj]
...

pcre2_match_data.c
C:\projects\tortoisegit-06nst\ext\pcre2\src\pcre2_match.c(5865,42): warning C4244: 'initializing': conversion from 'ptrdiff_t' to 'uint32_t', possible loss of data [C:\projects\tortoisegit-06nst\ext\build\pcre2.vcxproj]
PhilipHazel commented 7 months ago

I have added some casts that should get rid of these warnings - after checking that the values involved would never actually lose precision.

csware commented 7 months ago

Perfect, thanks!

Cross-ref: 7e0aa46c5d64942e5f1fe4f6cd9d558d98361e74

csware commented 7 months ago

There are still several warnings when compiling with /W4. But I doubt that fixing those will be easy...