[BRLTTY] Solaris memory leak, maybe windows too

Jason White jason at jasonjgw.net
Thu Aug 20 01:11:29 EDT 2009


I am also impressed with this outstanding effort on the part of Samuel and
Dave.

As an aside, I thought the dimensions of arrays in C and C++ had to be
determined at compile time, but apparently I was wrong, as this issue
demonstrates.

Variable-sized arrays also work in C++, at least with gcc 4.3. The following
compiles and runs. Based on a quick search, though, I couldn't find any
mention of it in K&R (2nd ed.), or any of the other books in my collection.


#include<iostream>
using namespace std;
int f(int x) {
  int a[x];
  for (int i = 0; i < x; i++)
    a[i] = i*i;
  for (int i = 0; i < x; i++)
    cout << i << '\t' << a[i] << endl;
}
int main() {
  int x;
  cin >> x;
  f(x);
}



More information about the BRLTTY mailing list