Questionable g++ behaviour

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am by no means a guru in C++, so I come to the list to ask advice. I have been informed that C++ does not allow for array declarations using varaibles as the size parameter:

<data_type> <array_name>[<variable>]

Yet g++ clearly allows this. Is this my misunderstanding? If so, can anyone point me in the direction of the appropriate C++ specs so that I may use as evidence? Or is this a bug or gotcha in g++? If so, should I file a bug report?

I have attached a sample .cpp which compiles and runs for me.

Thank you.
--
As a boy I jumped through Windows, as a man I play with Penguins.
#include <iostream>
using namespace std;

int main()
{
    int array_size = 5;
    int array[array_size];

    for (int i = 0; i < array_size; i++) {
        array[i] = i*i;
    }

    for (int i = 0; i < array_size; i++) {
        cout << array[i] << endl;
    }

    return 0;
}
-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux