Message ID | 20240221024638.1486832-1-raj.khem@gmail.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Hi 2024. február 21., szerda 3:46 keltezéssel, Khem Raj <raj.khem@gmail.com> írta: > Clang-18+ diagnoses this as error > > | ../git/src/ipa/rpi/controller/rpi/alsc.cpp:499:10: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] | 499 | int xLo[X], xHi[X]; > | | ^ > > Signed-off-by: Khem Raj <raj.khem@gmail.com> > --- > src/ipa/rpi/controller/rpi/alsc.cpp | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp > index 8a205c60..8c0ae8eb 100644 > --- a/src/ipa/rpi/controller/rpi/alsc.cpp > +++ b/src/ipa/rpi/controller/rpi/alsc.cpp > @@ -496,8 +496,8 @@ void resampleCalTable(const Array2D<double> &calTableIn, > * Precalculate and cache the x sampling locations and phases to save > * recomputing them on every row. > */ > - int xLo[X], xHi[X]; > - double xf[X]; > + int *xLo = (int*)alloca(X), *xHi = (int*)alloca(X); > + double *xf = (double*)alloca(X); > double scaleX = cameraMode.sensorWidth / > (cameraMode.width * cameraMode.scaleX); > double xOff = cameraMode.cropX / (double)cameraMode.sensorWidth; > -- > 2.43.2 This change is incorrect, the allocated sizes are insufficient. Also I am not sure going from VLA to alloca is really an improvement. Maybe the warning should be turned off. Or dynamic stack allocation should be eliminated altogether. Regards, Barnabás Pőcze
diff --git a/src/ipa/rpi/controller/rpi/alsc.cpp b/src/ipa/rpi/controller/rpi/alsc.cpp index 8a205c60..8c0ae8eb 100644 --- a/src/ipa/rpi/controller/rpi/alsc.cpp +++ b/src/ipa/rpi/controller/rpi/alsc.cpp @@ -496,8 +496,8 @@ void resampleCalTable(const Array2D<double> &calTableIn, * Precalculate and cache the x sampling locations and phases to save * recomputing them on every row. */ - int xLo[X], xHi[X]; - double xf[X]; + int *xLo = (int*)alloca(X), *xHi = (int*)alloca(X); + double *xf = (double*)alloca(X); double scaleX = cameraMode.sensorWidth / (cameraMode.width * cameraMode.scaleX); double xOff = cameraMode.cropX / (double)cameraMode.sensorWidth;
Clang-18+ diagnoses this as error | ../git/src/ipa/rpi/controller/rpi/alsc.cpp:499:10: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] | 499 | int xLo[X], xHi[X]; | | ^ Signed-off-by: Khem Raj <raj.khem@gmail.com> --- src/ipa/rpi/controller/rpi/alsc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)