Array initialization of bools
Gerald Pfeifer
pfeifer@dbai.tuwien.ac.at
Wed Nov 24 07:45:00 GMT 1999
On Wed, 24 Nov 1999, Bruce Eckel wrote:
> The following C++ program should initialize the elements as
> specified, and all the remaining elements in the array to
> false.
>
> #include <iostream>
> using namespace std;
>
> const int sz = 10;
> bool f[sz] = {false, true, true, false};
>
> int main() {
> for(int i = 0; i < sz; i++)
> cout << f[sz] << endl;
> }
GCC 2.95.1 does that, I just checked on sparc-sun-solaris2.6.
Your program most probably does not what you intended it to do in the
first place. You are always printing the same element -- f[sz] -- instead
of f[i].
Gerald
PS: Please note that a complete bug report also should include the version
of GCC you are using and the platform.
--
Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/
More information about the Gcc-bugs
mailing list