This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Initialization of constant 2D array
- To: gcc at gcc dot gnu dot org
- Subject: Initialization of constant 2D array
- From: Jimen Ching <jching at flex dot com>
- Date: Tue, 29 Aug 2000 21:32:29 -1000 (HST)
Hi all,
I am using gcc 2.95.2 on Debian, and the code below is getting the
following error message:
tst.cc: In function `void __static_initialization_and_destruction_0(int, int)':
tst.cc:11: conversion from `const abc[2]' to non-scalar type `abc' requested
tst.cc:11: conversion from `const abc[2]' to non-scalar type `abc' requested
Notice that only if a const is used that this error shows up. If you
compile without -DSHOW_BUG, it works fine. Is this a bug or does the new
C++ standard prevent initialization of a constant 2-D array?
--jc
---------------------------------------------
struct abc
{
abc(int i)
: data(i)
{ }
int data;
};
#ifdef SHOW_BUG
const abc xyz[][2] = { {1,1}, {2,2} };
#else
abc xyz[][2] = { {1,1}, {2,2} };
#endif
int
main()
{
return 0;
}
--
Jimen Ching (WH6BRR) jching@flex.com wh6brr@uhm.ampr.org