incompat: C++ Variable length array (VLA) not in C++ standard
It is a GNU extension, however.
There are 2 places VLAs are used.
I attempted to recode, paying careful attention to scoping and liveness,
and used new[] and delete[] instead.
See attached md file
bug: C++ Variable length array (VLA) not in C++ standard
It is a GNU extension, however.
There are 2 places VLAs are used.
I attempted to recode, paying careful attention to scoping and liveness,
and used new[] and delete[] instead.
```
diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp
index 27c22fe49..521f778e9 100644
--- a/widgets/mainwindow.cpp
+++ b/widgets/mainwindow.cpp
@@ -10643,7 +10643,8 @@ QString MainWindow::sortHoundCalls(QString t, int isort, int max_dB)
int nn=lines2.length();
if(isort==0) { // shuffle Hound calls to random order
- int a[nn];
+ //int a[nn];
+ int *a = new int[nn];
for(i=0; i<nn; i++) {
a[i]=i;
}
@@ -10656,6 +10657,7 @@ QString MainWindow::sortHoundCalls(QString t, int isort, int max_dB)
std::swap (a[j], a[i]);
t += lines2.at(a[i]) + "\n";
}
+ delete [] a; a = NULL;
}
```
```
diff --git a/widgets/plotter.cpp b/widgets/plotter.cpp
index fd64b3d02..4155a37ee 100644
--- a/widgets/plotter.cpp
+++ b/widgets/plotter.cpp
@@ -354,7 +354,7 @@ void CPlotter::drawRed(int ia, int ib, float swide[])
void CPlotter::replot()
{
resizeEvent(NULL);
- float swide[m_w];
+ float *swide = new float [m_w];
m_bReplot=true;
for(int irow=0; irow<m_h1; irow++) {
m_j=irow;
@@ -366,6 +366,7 @@ void CPlotter::replot()
}
update(); //trigger a new paintEvent
m_bReplot=false;
+ delete [] swide; swide = NULL;
}
void CPlotter::DrawOverlay() //DrawOverlay()
```
_______________________________________________
wsjt-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wsjt-devel