Opened 2 years ago

#130 new defect

Flexible array member of struct crashes CFA compiler when element type is generic

Reported by: mlbrooks Owned by:
Priority: minor Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

// this code causes the problem
forall (otype T)
struct s {
    int hdr;
    T bdy[];
};

// here is a workaround
forall (otype T)
struct s2 {
    int hdr;
    T bdy[0];
};

// FYI this works
struct s3 {
    int hdr;
    int bdy[];
};

Symptom on problem code = segmentation fault at:

Stack back trace for: /home/mlbrooks/cfa101/build/driver/cfa-cpp
(0) /lib/x86_64-linux-gnu/libc.so.6 : (/*unknown*/)+0x354b0 [0x7f7dea81d4b0]
(1) /home/mlbrooks/cfa101/build/driver/cfa-cpp : CodeGen::CodeGenerator::postvisit(UntypedExpr?*)+0x6ea [0x138de62]
(2) /home/mlbrooks/cfa101/build/driver/cfa-cpp() [0x1397ee0]
(3) /home/mlbrooks/cfa101/build/driver/cfa-cpp : void PassVisitor?<CodeGen::CodeGenerator>::call_postvisit<UntypedExpr?>(UntypedExpr?*)+0x2c [0x13c8ea2]
(4) /home/mlbrooks/cfa101/build/driver/cfa-cpp : PassVisitor?<CodeGen::CodeGenerator>::visit(UntypedExpr?*)+0x166 [0x13a251a]
(5) /home/mlbrooks/cfa101/build/driver/cfa-cpp : UntypedExpr::accept(Visitor&)+0x30 [0x2353dfe]
(6) /home/mlbrooks/cfa101/build/driver/cfa-cpp : CodeGen::CodeGenerator::postvisit(UntypedExpr?*)+0x707 [0x138de7f]
(7) /home/mlbrooks/cfa101/build/driver/cfa-cpp() [0x1397ee0]
(8) /home/mlbrooks/cfa101/build/driver/cfa-cpp : void PassVisitor?<CodeGen::CodeGenerator>::call_postvisit<UntypedExpr?>(UntypedExpr?*)+0x2c [0x13c8ea2]
(9) /home/mlbrooks/cfa101/build/driver/cfa-cpp : PassVisitor?<CodeGen::CodeGenerator>::visit(UntypedExpr?*)+0x166 [0x13a251a]
(10) /home/mlbrooks/cfa101/build/driver/cfa-cpp : UntypedExpr::accept(Visitor&)+0x30 [0x2353dfe]
(11) /home/mlbrooks/cfa101/build/driver/cfa-cpp : CodeGen::CodeGenerator::postvisit(CastExpr?*)+0x167 [0x138e457]
(12) /home/mlbrooks/cfa101/build/driver/cfa-cpp() [0x1397f84]
(13) /home/mlbrooks/cfa101/build/driver/cfa-cpp : void PassVisitor?<CodeGen::CodeGenerator>::call_postvisit<CastExpr?>(CastExpr?*)+0x2c [0x13c8f62]
(14) /home/mlbrooks/cfa101/build/driver/cfa-cpp : PassVisitor?<CodeGen::CodeGenerator>::visit(CastExpr?*)+0xe6 [0x13a279a]
(15) /home/mlbrooks/cfa101/build/driver/cfa-cpp : CastExpr::accept(Visitor&)+0x30 [0x2353f72]
(16) /home/mlbrooks/cfa101/build/driver/cfa-cpp : CodeGen::CodeGenerator::postvisit(ExprStmt?*)+0xa2 [0x139054c]
(17) /home/mlbrooks/cfa101/build/driver/cfa-cpp() [0x1397878]
(18) /home/mlbrooks/cfa101/build/driver/cfa-cpp : void PassVisitor?<CodeGen::CodeGenerator>::call_postvisit<ExprStmt?>(ExprStmt?*)+0x2c [0x13c7c84]
(19) /home/mlbrooks/cfa101/build/driver/cfa-cpp : PassVisitor?<CodeGen::CodeGenerator>::visit(ExprStmt?*)+0xc6 [0x13a05a2]
(20) /home/mlbrooks/cfa101/build/driver/cfa-cpp : ExprStmt::accept(Visitor&)+0x2e [0x235ec3e]
(21) /home/mlbrooks/cfa101/build/driver/cfa-cpp : CodeGen::CodeGenerator::postvisit(CompoundStmt?*)+0x130 [0x13903c6]
(22) /home/mlbrooks/cfa101/build/driver/cfa-cpp() [0x1397826]
(23) /home/mlbrooks/cfa101/build/driver/cfa-cpp : void PassVisitor?<CodeGen::CodeGenerator>::call_postvisit<CompoundStmt?>(CompoundStmt?*)+0x2c [0x13c7c24]
(24) /home/mlbrooks/cfa101/build/driver/cfa-cpp : PassVisitor?<CodeGen::CodeGenerator>::visit(CompoundStmt?*)+0x1b5 [0x13a0435]
(25) /home/mlbrooks/cfa101/build/driver/cfa-cpp : CompoundStmt::accept(Visitor&)+0x2e [0x23615e6]
(26) /home/mlbrooks/cfa101/build/driver/cfa-cpp : CodeGen::CodeGenerator::postvisit(FunctionDecl?*)+0x181 [0x138b731]
(27) /home/mlbrooks/cfa101/build/driver/cfa-cpp() [0x13974c7]
(28) /home/mlbrooks/cfa101/build/driver/cfa-cpp : void PassVisitor?<CodeGen::CodeGenerator>::call_postvisit<FunctionDecl?>(FunctionDecl?*)+0x2c [0x13c6b22]
(29) /home/mlbrooks/cfa101/build/driver/cfa-cpp : PassVisitor?<CodeGen::CodeGenerator>::visit(FunctionDecl?*)+0x440 [0x139f1fc]
(30) /home/mlbrooks/cfa101/build/driver/cfa-cpp : FunctionDecl::accept(Visitor&)+0x2e [0x2365f42]
(31) /home/mlbrooks/cfa101/build/driver/cfa-cpp : CodeGen::generate(std::cxx11::list<Declaration*, std::allocator<Declaration*> >, std::ostream&, bool, bool, bool, bool, bool)+0x1f0 [0x13e3cc4]
(32) /home/mlbrooks/cfa101/build/driver/cfa-cpp : main(/*unknown*/)+0xe90 [0x11f015e]
CFA Translator error: cfa-cpp failed with signal 6

Change History (0)

Note: See TracTickets for help on using tickets.