Opened 2 years ago

Last modified 2 years ago

#142 new defect

constant expression problem

Reported by: pabuhr Owned by:
Priority: major Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

The following works with gcc but fails with CFA.

struct S {
    int i;
};
enum { X = sizeof(struct S) };
int x[X];

cfa test5.cfa
CFA Version 1.0.0 (debug)
test5.cfa:4:1 error: Non-constexpr in initialization of enumerator: X: const instance of enum __anonymous0 with body 1 with initializer (not constructed)
  Simple Initializer: Generated Cast of:
    Sizeof Expression on: instance of struct S with body 1
  ... to:
    signed int
  ... with environment:
    Types:
    Non-types:

Change History (1)

comment:1 Changed 2 years ago by Rob Schluntz

This might be an easy fix. I would trace through ConstExprChecker and see what it's doing with this expression. Reading the code, I would have thought it would work, but maybe there's a hidden TypeExpr here? Apparently TypeExpr doesn't print any extra prefix (see TypeExpr::print), it might be worth adding one there to prevent confusion in the future.

Note: See TracTickets for help on using tickets.