This is the mail archive of the gcc-help@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]
Other format: [Raw text]

gcc brace enclosed initializer problem


We are getting an error due to superfluous braces in an initializer with g++ 3.3.3. The error is seen here:

% cat brace-enclosed-init.c
int main(void)
{
const char *menu[] =
           {
                   { "How now" },
                   { "Brown cow?" },
           };

           return 0;
}

% g++ -c brace-enclosed-init.c
brace-enclosed-init.c: In function `int main()':
brace-enclosed-init.c:7: error: brace-enclosed initializer used to
initialize `const char*'
brace-enclosed-init.c:7: error: brace-enclosed initializer used to
initialize `const char*'

We acknowledge that the braces are not needed, but it's not apparent why this should be an *error* rather than a mere warning as it is when the same code is compiled with gcc. We've squinted at ISO 14882 section 8.5.1 (dcl.init.aggr), but haven't seen why this should be an *error*. I understand that gcc/g++ is sometimes more standards compliant than other compilers, but we're not sure if this is the case here, and thought this might actually be a g++ bug.

--
     Jack Marr (marr@ugs.com)
     UGS -- Development Environment Tools
     Cypress, CA  "Ite Ursi"


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