[cfe-dev] "error: initializer element is not a compile-time constant"

Eli Friedman eli.friedman at gmail.com
Wed Jul 14 08:30:02 PDT 2010


On Wed, Jul 14, 2010 at 6:07 AM, Sascha Wildner <swildner at erpicon.de> wrote:
> Hi folks,
>
> the following file compiles fine with gcc (4.1.2) but errors with clang
> (108237). It's preprocessed source, and I've been too lazy to isolate a
> short test case, so apologies.
>
> http://yoyodyne.ath.cx/tmp/constant.c
>
> Output:
>
> --------------------
> zoot# env CCVER=gcc41 cc -c constant.c -o constant.o
> zoot# env CCVER=clang cc -c constant.c -o constant.o
> constant.c:4629:48: error: initializer element is not a compile-time
> constant
> static struct dm_report_field_type _fields[] = {
>                                                ^
> 1 diagnostic generated.
> --------------------
>
> So my question is, is there some knob to make clang behave like gcc
> here? I tried -std=gnu[89]9, but without success.

I think the particular folding required to implement the pointer
subtraction used here isn't implemented yet.  Feel free to file a bug,
or if you want to look into it yourself, the relevant code is
ExprConstant.cpp.

-Eli




More information about the cfe-dev mailing list