Opened 5 years ago

Closed 21 months ago

#142 closed defect (fixed)

constant expression problem

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


The following works with gcc but fails with CFA.

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

CFA Version 1.0.0 (debug) 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:

Change History (2)

comment:1 Changed 5 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.

comment:2 Changed 21 months ago by Thierry Delisle

Resolution: fixed
Status: newclosed

This code now compiles.

Note: See TracTickets for help on using tickets.