This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Initialization of constant 2D array


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]