Opened 3 years ago
Last modified 3 years ago
#251 new defect
C Array within tuple crashes the compiler
Reported by: | Thierry Delisle | Owned by: | |
---|---|---|---|
Priority: | minor | Component: | cfa-cc |
Version: | 1.0 | Keywords: | |
Cc: |
Description (last modified by )
Basic example:
[[] int, size_t] getarray() { int * a; size_t c; return [a, c]; }
Actual: That code crashes the compiler.
Null pointer (nullptr) dereference. Stack back trace for: driver/cfa-cpp (0) /lib/x86_64-linux-gnu/libc.so.6 : (/*unknown*/)+0x354c0 [0x7f1c0895b4c0] (1) driver/cfa-cpp : ast::print(std::ostream&, ast::Node const*, Indenter)+0x31 [0xb19791] (2) driver/cfa-cpp : ast::operator<<(std::ostream&, ast::Node const*)+0x18 [0xad73e8] (3) driver/cfa-cpp : ast::ArrayIterator::ArrayIterator(CodeLocation const&, ast::ArrayType const*)+0x19f [0x154a2ef] (4) driver/cfa-cpp : ast::createMemberIterator(CodeLocation const&, ast::Type const*)+0x169 [0x15428f9] (5) driver/cfa-cpp : ast::CurrentObject::enterListInit(CodeLocation const&)+0x4a [0x1542bda] (6) driver/cfa-cpp : ResolvExpr::Resolver_new::previsit(ast::ListInit const*)+0x2b [0x16a15db] (7) driver/cfa-cpp : ast::Pass<ResolvExpr::Resolver_new>::visit(ast::ListInit const*)+0x92 [0x1731652] (8) driver/cfa-cpp : ast::Pass<ResolvExpr::Resolver_new>::visit(ast::ObjectDecl const*)+0x1ae [0x172975e] (9) driver/cfa-cpp : std::vector<ast::ptr_base<ast::Decl, (ast::Node::ref_type)0> > ast::Pass<ResolvExpr::Resolver_new>::call_accept<std::vector, ast::Decl>(std::vector<ast::ptr_base<ast::Decl, (ast::Node::ref_type)0> > const&)+0x119 [0x172b0e9] (10) driver/cfa-cpp : ast::Pass<ResolvExpr::Resolver_new>::visit(ast::TupleType const*)+0x1b1 [0x172b4c1] (11) driver/cfa-cpp : ast::Pass<ResolvExpr::Resolver_new>::visit(ast::ObjectDecl const*)+0x14c [0x17296fc] (12) driver/cfa-cpp : std::vector<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0> > ast::Pass<ResolvExpr::Resolver_new>::call_accept<std::vector, ast::DeclWithType>(std::vector<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0> > const&)+0x119 [0x1729a29] (13) driver/cfa-cpp : void ast::Pass<ResolvExpr::Resolver_new>::maybe_accept<ast::FunctionDecl, ast::FunctionDecl, std::vector<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0>, std::allocator<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0> > > >(ast::FunctionDecl const*&, std::vector<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0>, std::allocator<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0> > > ast::FunctionDecl::*)+0x42 [0x172a1a2] (14) driver/cfa-cpp : ast::Pass<ResolvExpr::Resolver_new>::visit(ast::FunctionDecl const*)+0x1d5 [0x172a885] (15) driver/cfa-cpp : void ast::Pass<ResolvExpr::Resolver_new>::run<>(ast::TranslationUnit&)+0x1dc [0x16e906c] (16) driver/cfa-cpp : main(/*unknown*/)+0xa82 [0x9c9e82] Stack back trace for: driver/cfa-cpp (0) /lib/x86_64-linux-gnu/libc.so.6 : (/*unknown*/)+0x354c0 [0x7f1c0895b4c0] (1) driver/cfa-cpp : ast::print(std::ostream&, ast::Node const*, Indenter)+0x31 [0xb19791] (2) driver/cfa-cpp : ast::operator<<(std::ostream&, ast::Node const*)+0x18 [0xad73e8] (3) driver/cfa-cpp : ast::ArrayIterator::ArrayIterator(CodeLocation const&, ast::ArrayType const*)+0x19f [0x154a2ef] (4) driver/cfa-cpp : ast::createMemberIterator(CodeLocation const&, ast::Type const*)+0x169 [0x15428f9] (5) driver/cfa-cpp : ast::CurrentObject::enterListInit(CodeLocation const&)+0x4a [0x1542bda] (6) driver/cfa-cpp : ResolvExpr::Resolver_new::previsit(ast::ListInit const*)+0x2b [0x16a15db] (7) driver/cfa-cpp : ast::Pass<ResolvExpr::Resolver_new>::visit(ast::ListInit const*)+0x92 [0x1731652] (8) driver/cfa-cpp : ast::Pass<ResolvExpr::Resolver_new>::visit(ast::ObjectDecl const*)+0x1ae [0x172975e] (9) driver/cfa-cpp : std::vector<ast::ptr_base<ast::Decl, (ast::Node::ref_type)0> > ast::Pass<ResolvExpr::Resolver_new>::call_accept<std::vector, ast::Decl>(std::vector<ast::ptr_base<ast::Decl, (ast::Node::ref_type)0> > const&)+0x119 [0x172b0e9] (10) driver/cfa-cpp : ast::Pass<ResolvExpr::Resolver_new>::visit(ast::TupleType const*)+0x1b1 [0x172b4c1] (11) driver/cfa-cpp : ast::Pass<ResolvExpr::Resolver_new>::visit(ast::ObjectDecl const*)+0x14c [0x17296fc] (12) driver/cfa-cpp : std::vector<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0> > ast::Pass<ResolvExpr::Resolver_new>::call_accept<std::vector, ast::DeclWithType>(std::vector<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0> > const&)+0x119 [0x1729a29] (13) driver/cfa-cpp : void ast::Pass<ResolvExpr::Resolver_new>::maybe_accept<ast::FunctionDecl, ast::FunctionDecl, std::vector<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0>, std::allocator<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0> > > >(ast::FunctionDecl const*&, std::vector<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0>, std::allocator<ast::ptr_base<ast::DeclWithType, (ast::Node::ref_type)0> > > ast::FunctionDecl::*)+0x42 [0x172a1a2] (14) driver/cfa-cpp : ast::Pass<ResolvExpr::Resolver_new>::visit(ast::FunctionDecl const*)+0x1d5 [0x172a885] (15) driver/cfa-cpp : void ast::Pass<ResolvExpr::Resolver_new>::run<>(ast::TranslationUnit&)+0x1dc [0x16e906c] (16) driver/cfa-cpp : main(/*unknown*/)+0xa82 [0x9c9e82]
Expected (all examples): Same as for type [* int, size_t].
Other examples that produce similar crashes, each on its own:
[[] int, size_t] f(); [void] f( [[] int, size_t] arg ); void f() { [[] int, size_t] var; }
This behaviour is consistent with the description: Decay from type [[] foo] to type [* foo] is not being attempted within tuples, but is required to happen.
Change History (1)
comment:1 Changed 3 years ago by
Description: | modified (diff) |
---|---|
Summary: | Array within tuple return crashes the compiler → C Array within tuple crashes the compiler |
Note: See
TracTickets for help on using
tickets.