Re: Declarations cause "Error: Non-static-const variable in array dimension"

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Thu, 8 Apr 2010 14:24:39 +0200


Hi,

Benjamin Bannier wrote on 04/08/2010 01:55 PM:

>> Ida, that's basic C++, not ROOT specific issue.
>> Do you really want to bother this list with it?!

>
> not to make too much noise myself, but this code actually compiles fine
> in gcc-4.3.2, but CINT treats it as an error.

the standard says "An integral constant-expression can involve only literals (2.13), enumerators, const variables or static data members of integral or enumeration types initialized with constant expressions (8.5), non-type template parameters of integral or enumeration types, and sizeof expressions." And an integral constant-expression (ICE) is what's needed to declare an array's size.

GCC 4.3 has an extension where it tracks the values of non-const variables, and if they are unchanged allows them to be used as ICEs (at least that's my interpretation of what it does). It even tracks the use of some function calls if they don't have side effects: sin(ICE) is an ICE itself. It mixes in a bit of C++ 0x into the current C++; only C++ 0x defines tracking of ICEs. So this time you've found a GCC extension, not a CINT limitation :-)

Cheers, Axel. Received on Thu Apr 08 2010 - 14:24:39 CEST

This archive was generated by hypermail 2.2.0 : Thu Apr 08 2010 - 17:50:02 CEST