diff --git a/.github/scripts/windows/build_task.bat b/.github/scripts/windows/build_task.bat index fd9a956bd38fb..2d7d4031c47f2 100644 --- a/.github/scripts/windows/build_task.bat +++ b/.github/scripts/windows/build_task.bat @@ -32,7 +32,7 @@ if "%THREAD_SAFE%" equ "0" set ADD_CONF=%ADD_CONF% --disable-zts if "%INTRINSICS%" neq "" set ADD_CONF=%ADD_CONF% --enable-native-intrinsics=%INTRINSICS% if "%ASAN%" equ "1" set ADD_CONF=%ADD_CONF% --enable-sanitizer --enable-debug-pack -set CFLAGS=/W1 /WX /w14013 +set CFLAGS=/W2 /WX /w14013 /wd4146 /wd4305 cmd /c configure.bat ^ --enable-snapshot-build ^ diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 44a90773ee12d..649566f55b4d0 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1134,7 +1134,7 @@ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color) TBB: but watch out for /0! */ double ac = cos (atan2 (dy, dx)); if (ac != 0) { - wid = thick / ac; + wid = (int) (thick / ac); } else { wid = 1; } @@ -1198,7 +1198,7 @@ TBB: but watch out for /0! */ TBB: but watch out for /0! */ double as = sin (atan2 (dy, dx)); if (as != 0) { - wid = thick / as; + wid = (int) (thick / as); } else { wid = 1; } @@ -1388,7 +1388,7 @@ void gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color TBB: but watch out for /0! */ double as = sin(atan2(dy, dx)); if (as != 0) { - wid = thick / as; + wid = (int) (thick / as); } else { wid = 1; } @@ -1437,7 +1437,7 @@ void gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color TBB: but watch out for /0! */ double as = sin (atan2 (dy, dx)); if (as != 0) { - wid = thick / as; + wid = (int) (thick / as); } else { wid = 1; } @@ -2827,7 +2827,7 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c) * same footprint. */ if (y >= y1 && y < y2) { - im->polyInts[ints++] = (float) ((y - y1) * (x2 - x1)) / (float) (y2 - y1) + 0.5 + x1; + im->polyInts[ints++] = (int) ((float) ((y - y1) * (x2 - x1)) / (float) (y2 - y1) + 0.5 + x1); } else if (y == pmaxy && y == y2) { im->polyInts[ints++] = x2; } diff --git a/ext/gd/libgd/gd_avif.c b/ext/gd/libgd/gd_avif.c index 9c1ffdc34bc68..e1d9adb179755 100644 --- a/ext/gd/libgd/gd_avif.c +++ b/ext/gd/libgd/gd_avif.c @@ -81,7 +81,7 @@ static int quality2Quantizer(int quality) { float scaleFactor = (float) AVIF_QUANTIZER_WORST_QUALITY / (float) MAX_QUALITY; - return round(scaleFactor * (MAX_QUALITY - clampedQuality)); + return (int) round(scaleFactor * (MAX_QUALITY - clampedQuality)); } /* @@ -103,7 +103,7 @@ static avifBool setEncoderTilesAndThreads(avifEncoder *encoder, avifRGBImage *rg // The number of tiles in any dimension will always be a power of 2. We can only specify log(2)tiles. - tilesLog2 = floor(log2(tiles)); + tilesLog2 = (int) floor(log2(tiles)); // If the image's width is greater than the height, use more tile columns // than tile rows to make the tile size close to a square. diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index b08cc64aa30da..cb57b927046a5 100644 --- a/ext/gd/libgd/gd_interpolation.c +++ b/ext/gd/libgd/gd_interpolation.c @@ -2137,8 +2137,7 @@ gdImagePtr gdImageRotateInterpolated(const gdImagePtr src, const float angle, in /* round to two decimals and keep the 100x multiplication to use it in the common square angles case later. Keep the two decimal precisions so smaller rotation steps can be done, useful for slow animations. */ - const int angle_rounded = fmod((int) floorf(angle * 100), 360 * 100); - + const int angle_rounded = (int) fmod((int) floorf(angle * 100), 360 * 100); if (bgcolor < 0) { return NULL; } diff --git a/ext/gd/libgd/gd_webp.c b/ext/gd/libgd/gd_webp.c index 6277e09710f9e..df3b52848cec7 100644 --- a/ext/gd/libgd/gd_webp.c +++ b/ext/gd/libgd/gd_webp.c @@ -156,7 +156,7 @@ void gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality) if (quality >= gdWebpLossless) { out_size = WebPEncodeLosslessRGBA(argb, gdImageSX(im), gdImageSY(im), gdImageSX(im) * 4, &out); } else { - out_size = WebPEncodeRGBA(argb, gdImageSX(im), gdImageSY(im), gdImageSX(im) * 4, quality, &out); + out_size = WebPEncodeRGBA(argb, gdImageSX(im), gdImageSY(im), gdImageSX(im) * 4, (float) quality, &out); } if (out_size == 0) { diff --git a/ext/intl/collator/collator_convert.c b/ext/intl/collator/collator_convert.c index 463348f2a196b..2a5c379705845 100644 --- a/ext/intl/collator/collator_convert.c +++ b/ext/intl/collator/collator_convert.c @@ -290,7 +290,7 @@ zval* collator_convert_string_to_double( zval* str, zval *rv ) zval* num = collator_convert_string_to_number( str, rv ); if( Z_TYPE_P(num) == IS_LONG ) { - ZVAL_DOUBLE( num, Z_LVAL_P( num ) ); + ZVAL_DOUBLE( num, (double) Z_LVAL_P( num ) ); } return num; diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.c index de3b8191e9e24..6294ecbadcaee 100644 --- a/ext/intl/formatter/formatter_parse.c +++ b/ext/intl/formatter/formatter_parse.c @@ -76,7 +76,7 @@ PHP_FUNCTION( numfmt_parse ) case FORMAT_TYPE_INT64: val64 = unum_parseInt64(FORMATTER_OBJECT(nfo), sstr, sstr_len, position_p, &INTL_DATA_ERROR_CODE(nfo)); if(val64 > ZEND_LONG_MAX || val64 < ZEND_LONG_MIN) { - RETVAL_DOUBLE(val64); + RETVAL_DOUBLE((double) val64); } else { RETVAL_LONG((zend_long)val64); } diff --git a/ext/random/gammasection.c b/ext/random/gammasection.c index 732f8a2b0d9b6..a7c15ced44509 100644 --- a/ext/random/gammasection.c +++ b/ext/random/gammasection.c @@ -51,8 +51,8 @@ static double gamma_max(double x, double y) static void splitint64(uint64_t v, double *vhi, double *vlo) { - *vhi = v >> 2; - *vlo = v & UINT64_C(0x3); + *vhi = (double) (v >> 2); + *vlo = (double) (v & UINT64_C(0x3)); } static uint64_t ceilint(double a, double b, double g) diff --git a/ext/random/random.c b/ext/random/random.c index 46a6c4fd44f2c..502679ea48cd6 100644 --- a/ext/random/random.c +++ b/ext/random/random.c @@ -473,7 +473,7 @@ PHPAPI zend_long php_mt_rand_common(zend_long min, zend_long max) /* This is an inlined version of the RAND_RANGE_BADSCALING macro that does not invoke UB when encountering * (max - min) > ZEND_LONG_MAX. */ - zend_ulong offset = (double) ( (double) max - min + 1.0) * (r / (PHP_MT_RAND_MAX + 1.0)); + zend_ulong offset = (zend_ulong) (((double) max - min + 1.0) * (r / (PHP_MT_RAND_MAX + 1.0))); return (zend_long) (offset + min); } diff --git a/ext/random/randomizer.c b/ext/random/randomizer.c index 0585ea95e668e..34708ab756033 100644 --- a/ext/random/randomizer.c +++ b/ext/random/randomizer.c @@ -256,7 +256,7 @@ PHP_METHOD(Random_Randomizer, getInt) /* This is an inlined version of the RAND_RANGE_BADSCALING macro that does not invoke UB when encountering * (max - min) > ZEND_LONG_MAX. */ - zend_ulong offset = (double) ( (double) max - min + 1.0) * (r / (PHP_MT_RAND_MAX + 1.0)); + zend_ulong offset = (zend_ulong) (((double) max - min + 1.0) * (r / (PHP_MT_RAND_MAX + 1.0))); result = (zend_long) (offset + min); } else {