From 8f56c2af4617cc16f352cd77bd827bfe6401f314 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 8 Aug 2026 13:26:26 +0000 Subject: [PATCH 1/3] fix: pass const qualified views in `blas/ext/base/ndarray` packages Propagates fix from ebbf2de9f ("fix: pass const qualified views") to sibling packages with the same addon argument handling. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01WX6uDwjW9prE4N4VY8qwSu --- .../@stdlib/blas/ext/base/ndarray/dnansum/src/addon.c | 6 +++++- .../@stdlib/blas/ext/base/ndarray/dsum/src/addon.c | 6 +++++- .../@stdlib/blas/ext/base/ndarray/snansum/src/addon.c | 6 +++++- .../@stdlib/blas/ext/base/ndarray/ssum/src/addon.c | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansum/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansum/src/addon.c index d01905481d67..7b558d72490b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansum/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dnansum/src/addon.c @@ -45,8 +45,12 @@ static napi_value addon( napi_env env, napi_callback_info info ) { assert( status == napi_ok ); return NULL; } + // Create a const-qualified view of the argument pointer list: + const struct ndarray *arr[ 1 ] = { + arrays[ 0 ] + }; // Perform computation: - STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_blas_ext_dnansum( arrays ), v ); + STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_blas_ext_dnansum( arr ), v ); // Free allocated memory: stdlib_ndarray_free( arrays[ 0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsum/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsum/src/addon.c index 8ee9372b2722..270d8e4f418b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsum/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dsum/src/addon.c @@ -45,8 +45,12 @@ static napi_value addon( napi_env env, napi_callback_info info ) { assert( status == napi_ok ); return NULL; } + // Create a const-qualified view of the argument pointer list: + const struct ndarray *arr[ 1 ] = { + arrays[ 0 ] + }; // Perform computation: - STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_blas_ext_dsum( arrays ), v ); + STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_blas_ext_dsum( arr ), v ); // Free allocated memory: stdlib_ndarray_free( arrays[ 0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansum/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansum/src/addon.c index 575e47dd18bf..cabcf29bf02f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansum/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/snansum/src/addon.c @@ -45,8 +45,12 @@ static napi_value addon( napi_env env, napi_callback_info info ) { assert( status == napi_ok ); return NULL; } + // Create a const-qualified view of the argument pointer list: + const struct ndarray *arr[ 1 ] = { + arrays[ 0 ] + }; // Perform computation: - STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_blas_ext_snansum( arrays ), v ); + STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_blas_ext_snansum( arr ), v ); // Free allocated memory: stdlib_ndarray_free( arrays[ 0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssum/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssum/src/addon.c index 4f9f07896863..a6dade6a78d0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssum/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/ssum/src/addon.c @@ -45,8 +45,12 @@ static napi_value addon( napi_env env, napi_callback_info info ) { assert( status == napi_ok ); return NULL; } + // Create a const-qualified view of the argument pointer list: + const struct ndarray *arr[ 1 ] = { + arrays[ 0 ] + }; // Perform computation: - STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_blas_ext_ssum( arrays ), v ); + STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_blas_ext_ssum( arr ), v ); // Free allocated memory: stdlib_ndarray_free( arrays[ 0 ] ); From 567388e9fa807e2cbd4451f849d4d8e4e9c8de8d Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 8 Aug 2026 13:26:32 +0000 Subject: [PATCH 2/3] chore: replace VLAs with heap allocation in C benchmarks Propagates fix from f19d370e0 ("chore: clean-up") to the remaining C benchmark files containing stack-allocated variable-length arrays. Ref: https://github.com/stdlib-js/stdlib/issues/8643 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01WX6uDwjW9prE4N4VY8qwSu --- .../base/zdscal/benchmark/c/benchmark.length.c | 8 ++++++-- .../dnanmskmin/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../dnanmskrange/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../scumax/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../scumaxabs/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../scumin/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../scuminabs/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../smskmax/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../smskmin/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../smskrange/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../snanmskmax/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../snanmskmin/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../snanmskrange/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../sztest/benchmark/c/benchmark.length.c | 8 ++++++-- .../sztest2/benchmark/c/benchmark.length.c | 16 ++++++++++++---- .../base/cmap/benchmark/c/benchmark.length.c | 8 ++++++-- 16 files changed, 174 insertions(+), 58 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c index e4124b662fb7..105ae5556dff 100644 --- a/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c @@ -99,11 +99,12 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - stdlib_complex128_t x[ len ]; + stdlib_complex128_t *x; double elapsed; double t; int i; + x = (stdlib_complex128_t *)malloc( len * sizeof( stdlib_complex128_t ) ); for ( i = 0; i < len; i++ ) { x[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); } @@ -119,6 +120,7 @@ static double benchmark1( int iterations, int len ) { if ( stdlib_base_is_nan( stdlib_complex128_imag( x[ i%len ] ) ) ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; } @@ -130,11 +132,12 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - stdlib_complex128_t x[ len ]; + stdlib_complex128_t *x; double elapsed; double t; int i; + x = (stdlib_complex128_t *)malloc( len * sizeof( stdlib_complex128_t ) ); for ( i = 0; i < len; i++ ) { x[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); } @@ -150,6 +153,7 @@ static double benchmark2( int iterations, int len ) { if ( stdlib_base_is_nan( stdlib_complex128_real( x[ i%len ] ) ) ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/dnanmskmin/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/dnanmskmin/benchmark/c/benchmark.length.c index 0c88559e61c5..2049daaa61f5 100644 --- a/lib/node_modules/@stdlib/stats/strided/dnanmskmin/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/dnanmskmin/benchmark/c/benchmark.length.c @@ -95,13 +95,15 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - double x[ len ]; + double *x; double v; double t; int i; + x = (double *)malloc( len * sizeof( double ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_double() < 0.2 ) { mask[ i ] = 1; // missing @@ -124,6 +126,8 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } @@ -135,13 +139,15 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - double x[ len ]; + double *x; double v; double t; int i; + x = (double *)malloc( len * sizeof( double ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_double() < 0.2 ) { mask[ i ] = 1; // missing @@ -164,6 +170,8 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/dnanmskrange/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/dnanmskrange/benchmark/c/benchmark.length.c index 4ae1e5cec199..f802b1b844ce 100644 --- a/lib/node_modules/@stdlib/stats/strided/dnanmskrange/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/dnanmskrange/benchmark/c/benchmark.length.c @@ -95,13 +95,15 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - double x[ len ]; + double *x; double v; double t; int i; + x = (double *)malloc( len * sizeof( double ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_double() < 0.2 ) { mask[ i ] = 1; // missing @@ -124,6 +126,8 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } @@ -135,13 +139,15 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - double x[ len ]; + double *x; double v; double t; int i; + x = (double *)malloc( len * sizeof( double ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_double() < 0.2 ) { mask[ i ] = 1; // missing @@ -164,6 +170,8 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/scumax/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/scumax/benchmark/c/benchmark.length.c index 17e1bb32321b..c18e368070b8 100644 --- a/lib/node_modules/@stdlib/stats/strided/scumax/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/scumax/benchmark/c/benchmark.length.c @@ -96,11 +96,13 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + y = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f; y[ i ] = 0.0f; @@ -118,6 +120,8 @@ static double benchmark1( int iterations, int len ) { if ( y[ len-1 ] != y[ len-1 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } @@ -130,11 +134,13 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + y = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f; y[ i ] = 0.0f; @@ -152,6 +158,8 @@ static double benchmark2( int iterations, int len ) { if ( y[ len-1 ] != y[ len-1 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/scumaxabs/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/scumaxabs/benchmark/c/benchmark.length.c index 1ef600bc1eaf..9187326d1c79 100644 --- a/lib/node_modules/@stdlib/stats/strided/scumaxabs/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/scumaxabs/benchmark/c/benchmark.length.c @@ -96,11 +96,13 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + y = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f; y[ i ] = 0.0f; @@ -118,6 +120,8 @@ static double benchmark1( int iterations, int len ) { if ( y[ len-1 ] != y[ len-1 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } @@ -130,11 +134,13 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + y = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f; y[ i ] = 0.0f; @@ -152,6 +158,8 @@ static double benchmark2( int iterations, int len ) { if ( y[ len-1 ] != y[ len-1 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/scumin/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/scumin/benchmark/c/benchmark.length.c index c89499eaefaf..9c0b521dc782 100644 --- a/lib/node_modules/@stdlib/stats/strided/scumin/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/scumin/benchmark/c/benchmark.length.c @@ -96,11 +96,13 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + y = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f; y[ i ] = 0.0f; @@ -118,6 +120,8 @@ static double benchmark1( int iterations, int len ) { if ( y[ len-1 ] != y[ len-1 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } @@ -130,11 +134,13 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + y = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f; y[ i ] = 0.0f; @@ -152,6 +158,8 @@ static double benchmark2( int iterations, int len ) { if ( y[ len-1 ] != y[ len-1 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/scuminabs/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/scuminabs/benchmark/c/benchmark.length.c index 39fc858c1ac9..8a3a956db77e 100644 --- a/lib/node_modules/@stdlib/stats/strided/scuminabs/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/scuminabs/benchmark/c/benchmark.length.c @@ -96,11 +96,13 @@ static float rand_float( void ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + y = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f; y[ i ] = 0.0f; @@ -118,6 +120,8 @@ static double benchmark1( int iterations, int len ) { if ( y[ len-1 ] != y[ len-1 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } @@ -130,11 +134,13 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + y = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f; y[ i ] = 0.0f; @@ -152,6 +158,8 @@ static double benchmark2( int iterations, int len ) { if ( y[ len-1 ] != y[ len-1 ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/smskmax/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/smskmax/benchmark/c/benchmark.length.c index 0e3d2f578daf..f1b8cb76d7e0 100644 --- a/lib/node_modules/@stdlib/stats/strided/smskmax/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/smskmax/benchmark/c/benchmark.length.c @@ -95,13 +95,15 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -124,6 +126,8 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } @@ -135,13 +139,15 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -164,6 +170,8 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/smskmin/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/smskmin/benchmark/c/benchmark.length.c index a2fa2391d71e..f13c64bb0878 100644 --- a/lib/node_modules/@stdlib/stats/strided/smskmin/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/smskmin/benchmark/c/benchmark.length.c @@ -95,13 +95,15 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -124,6 +126,8 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } @@ -135,13 +139,15 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -164,6 +170,8 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/smskrange/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/smskrange/benchmark/c/benchmark.length.c index f154599e43ab..9097a94e8a1f 100644 --- a/lib/node_modules/@stdlib/stats/strided/smskrange/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/smskrange/benchmark/c/benchmark.length.c @@ -95,13 +95,15 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -124,6 +126,8 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } @@ -135,13 +139,15 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -164,6 +170,8 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/snanmskmax/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/snanmskmax/benchmark/c/benchmark.length.c index 50fc631f65d8..6ab82e92f130 100644 --- a/lib/node_modules/@stdlib/stats/strided/snanmskmax/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/snanmskmax/benchmark/c/benchmark.length.c @@ -95,13 +95,15 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -124,6 +126,8 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } @@ -135,13 +139,15 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -164,6 +170,8 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/snanmskmin/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/snanmskmin/benchmark/c/benchmark.length.c index 0404c0b4b41f..3caff0fbf0b3 100644 --- a/lib/node_modules/@stdlib/stats/strided/snanmskmin/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/snanmskmin/benchmark/c/benchmark.length.c @@ -95,13 +95,15 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -124,6 +126,8 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } @@ -135,13 +139,15 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -164,6 +170,8 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/snanmskrange/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/snanmskrange/benchmark/c/benchmark.length.c index 6bf97d7c068b..6a7b00ccc60c 100644 --- a/lib/node_modules/@stdlib/stats/strided/snanmskrange/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/snanmskrange/benchmark/c/benchmark.length.c @@ -95,13 +95,15 @@ static float rand_float( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -124,6 +126,8 @@ static double benchmark1( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } @@ -135,13 +139,15 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - unsigned char mask[ len ]; + unsigned char *mask; double elapsed; - float x[ len ]; + float *x; float v; double t; int i; + x = (float *)malloc( len * sizeof( float ) ); + mask = (unsigned char *)malloc( len * sizeof( unsigned char ) ); for ( i = 0; i < len; i++ ) { if ( rand_float() < 0.2f ) { mask[ i ] = 1; // missing @@ -164,6 +170,8 @@ static double benchmark2( int iterations, int len ) { if ( v != v ) { printf( "should not return NaN\n" ); } + free( x ); + free( mask ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/sztest/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/sztest/benchmark/c/benchmark.length.c index 55e3d18ee7da..f66107a42031 100644 --- a/lib/node_modules/@stdlib/stats/strided/sztest/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/sztest/benchmark/c/benchmark.length.c @@ -100,7 +100,7 @@ static float random_uniform( const float min, const float max ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - float x[ len ]; + float *x; double t; int i; @@ -115,6 +115,7 @@ static double benchmark1( int iterations, int len ) { .sd = 0.0f }; + x = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = random_uniform( -5.0f, 5.0f ); } @@ -131,6 +132,7 @@ static double benchmark1( int iterations, int len ) { if ( results.statistic != results.statistic ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; } @@ -143,7 +145,7 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - float x[ len ]; + float *x; double t; int i; @@ -158,6 +160,7 @@ static double benchmark2( int iterations, int len ) { .sd = 0.0f }; + x = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = random_uniform( -5.0f, 5.0f ); } @@ -174,6 +177,7 @@ static double benchmark2( int iterations, int len ) { if ( results.statistic != results.statistic ) { printf( "should not return NaN\n" ); } + free( x ); return elapsed; } diff --git a/lib/node_modules/@stdlib/stats/strided/sztest2/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/strided/sztest2/benchmark/c/benchmark.length.c index 40b774a9b9c9..fbd8878731f5 100644 --- a/lib/node_modules/@stdlib/stats/strided/sztest2/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/strided/sztest2/benchmark/c/benchmark.length.c @@ -100,8 +100,8 @@ static float random_uniform( const float min, const float max ) { */ static double benchmark1( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; @@ -117,6 +117,8 @@ static double benchmark1( int iterations, int len ) { .ymean = 0.0f }; + x = (float *)malloc( len * sizeof( float ) ); + y = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = random_uniform( -5.0f, 5.0f ); y[ i ] = random_uniform( -5.0f, 5.0f ); @@ -134,6 +136,8 @@ static double benchmark1( int iterations, int len ) { if ( results.statistic != results.statistic ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } @@ -146,8 +150,8 @@ static double benchmark1( int iterations, int len ) { */ static double benchmark2( int iterations, int len ) { double elapsed; - float x[ len ]; - float y[ len ]; + float *x; + float *y; double t; int i; @@ -163,6 +167,8 @@ static double benchmark2( int iterations, int len ) { .ymean = 0.0f }; + x = (float *)malloc( len * sizeof( float ) ); + y = (float *)malloc( len * sizeof( float ) ); for ( i = 0; i < len; i++ ) { x[ i ] = random_uniform( -5.0f, 5.0f ); y[ i ] = random_uniform( -5.0f, 5.0f ); @@ -180,6 +186,8 @@ static double benchmark2( int iterations, int len ) { if ( results.statistic != results.statistic ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } diff --git a/lib/node_modules/@stdlib/strided/base/cmap/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/strided/base/cmap/benchmark/c/benchmark.length.c index c03882b64be1..e85c01f02a4b 100644 --- a/lib/node_modules/@stdlib/strided/base/cmap/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/strided/base/cmap/benchmark/c/benchmark.length.c @@ -106,12 +106,14 @@ static float complex identity( const float complex x ) { * @return elapsed time in seconds */ static double benchmark( int iterations, int len ) { - float complex x[ len ]; - float complex y[ len ]; + float complex *x; + float complex *y; double elapsed; double t; int i; + x = (float complex *)malloc( len * sizeof( float complex ) ); + y = (float complex *)malloc( len * sizeof( float complex ) ); for ( i = 0; i < len; i++ ) { x[ i ] = ( ( rand_float()*200.0f ) - 100.0f ) + ( ( rand_float()*200.0f ) - 100.0f )*I; y[ i ] = 0.0f + 0.0f*I; @@ -129,6 +131,8 @@ static double benchmark( int iterations, int len ) { if ( y[ i%len ] != y[ i%len ] ) { printf( "should not return NaN\n" ); } + free( x ); + free( y ); return elapsed; } From 1f1bb98aefe6dc358a4bc8ba6324b3d443faf79e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 8 Aug 2026 13:34:43 +0000 Subject: [PATCH 3/3] chore: exclude `blas/base/zdscal` from VLA conversion Reverts the heap-allocation conversion for `blas/base/zdscal`, as cppcheck cannot track initialization of malloc'd `stdlib_complex128_t` elements assigned via function call and reports `uninitdata` errors at the post-loop `x[ i%len ]` reads. The repository has no precedent for suppressing `uninitdata`, and restructuring the benchmark is beyond the scope of the propagated pattern. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01WX6uDwjW9prE4N4VY8qwSu --- .../blas/base/zdscal/benchmark/c/benchmark.length.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c index 105ae5556dff..e4124b662fb7 100644 --- a/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/base/zdscal/benchmark/c/benchmark.length.c @@ -99,12 +99,11 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - stdlib_complex128_t *x; + stdlib_complex128_t x[ len ]; double elapsed; double t; int i; - x = (stdlib_complex128_t *)malloc( len * sizeof( stdlib_complex128_t ) ); for ( i = 0; i < len; i++ ) { x[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); } @@ -120,7 +119,6 @@ static double benchmark1( int iterations, int len ) { if ( stdlib_base_is_nan( stdlib_complex128_imag( x[ i%len ] ) ) ) { printf( "should not return NaN\n" ); } - free( x ); return elapsed; } @@ -132,12 +130,11 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - stdlib_complex128_t *x; + stdlib_complex128_t x[ len ]; double elapsed; double t; int i; - x = (stdlib_complex128_t *)malloc( len * sizeof( stdlib_complex128_t ) ); for ( i = 0; i < len; i++ ) { x[ i ] = stdlib_complex128( (rand_double()*10000.0)-5000.0, (rand_double()*10000.0)-5000.0 ); } @@ -153,7 +150,6 @@ static double benchmark2( int iterations, int len ) { if ( stdlib_base_is_nan( stdlib_complex128_real( x[ i%len ] ) ) ) { printf( "should not return NaN\n" ); } - free( x ); return elapsed; }