elliotchance / c2go

⚖️ A tool for transpiling C to Go.
MIT License
2.09k stars 154 forks source link

panic: cannot do unary on: &ast.StringLiteral{Addr:0x5630aebd4b70, Pos:ast.Positio n{File:"/home/1828_sandbox/src/the-language/core/arch/c/lang.c", Line:1484, LineEn d:0, Column:54, ColumnEnd:0, StringValue:""}, Type:"char [18]", Value:"TheLanguage PANIC", Lvalue:true, ChildNodes:[]ast.Node{}} #823

Closed zaoqi closed 4 years ago

zaoqi commented 5 years ago

https://gitlab.com/the-language/the-language/blob/ba1faf026ca6f4b57d7ec3e7babed3f088ff2130/core/arch/c/lang.c

panic: cannot do unary on: &ast.StringLiteral{Addr:0x5602b7d03b70, Pos:ast.Position{File:"/home/1828_sandbox/src/the-language/core/arch/c/lang.c", Line:1484, LineEnd:0, Column:54, ColumnEnd:0, StringValue:""}, Type:"char [18]", Value:"TheLanguage PANIC", Lvalue:true, ChildNodes:[]ast.Node{}}

goroutine 1 [running]:
github.com/elliotchance/c2go/transpiler.transpileUnaryExprOrTypeTraitExpr(0xc003f639a0, 0xc0000a05a0, 0xc006cf0cb8, 0xc006cf0cd0, 0x4d4310, 0xc00054b890, 0xb, 0x6c2938, 0x6, 0xc000024588, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/unary.go:721 +0x491
github.com/elliotchance/c2go/transpiler.transpileToExpr(0x709480, 0xc003f639a0, 0xc0000a05a0, 0xc0050c6900, 0x0, 0x0, 0x0, 0x0, 0x8dd390, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:198 +0x27a
github.com/elliotchance/c2go/transpiler.atomicOperation(0x709480, 0xc003f639a0, 0xc0000a05a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/operators.go:494 +0xa5
github.com/elliotchance/c2go/transpiler.transpileBinaryOperator(0xc000e9c870, 0xc0000a05a0, 0xc006cf1600, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/binary.go:215 +0xb4f
github.com/elliotchance/c2go/transpiler.transpileToExpr(0x707ec0, 0xc000e9c870, 0xc0000a05a0, 0xc0000a0500, 0x0, 0x0, 0x0, 0x0, 0x8dd390, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:165 +0xe2f
github.com/elliotchance/c2go/transpiler.transpileParenExpr(0xc000e9c7e0, 0xc0000a05a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/operators.go:160 +0xfc
github.com/elliotchance/c2go/transpiler.transpileToExpr(0x708ec0, 0xc000e9c7e0, 0xc0000a05a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8dd390, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:183 +0xce2
github.com/elliotchance/c2go/transpiler.atomicOperation(0x708ec0, 0xc000e9c7e0, 0xc0000a05a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/operators.go:494 +0xa5
github.com/elliotchance/c2go/transpiler.transpileBinaryOperator(0xc000e9c750, 0xc0000a05a0, 0xc006cf2300, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/binary.go:215 +0xb4f
github.com/elliotchance/c2go/transpiler.transpileToExpr(0x707ec0, 0xc000e9c750, 0xc0000a05a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8dd390, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:165 +0xe2f
github.com/elliotchance/c2go/transpiler.transpileCallExpr(0xc0019d0460, 0xc0000a05a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/call.go:312 +0x1349
github.com/elliotchance/c2go/transpiler.transpileToExpr(0x708040, 0xc0019d0460, 0xc0000a05a0, 0xc006cf2a01, 0x0, 0x0, 0x0, 0x0, 0x8dd390, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:192 +0x7a9
github.com/elliotchance/c2go/transpiler.transpileToStmt(0x708040, 0xc0019d0460, 0xc0000a05a0, 0x0, 0x0, 0x8dd390, 0x0, 0x0, 0x8dd390, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:387 +0x1ad
github.com/elliotchance/c2go/transpiler.transpileToStmts(0x708040, 0xc0019d0460, 0xc0000a05a0, 0x8dd390, 0x0, 0x0, 0x0, 0x0)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:265 +0xe3
github.com/elliotchance/c2go/transpiler.transpileCompoundStmt(0xc001847f10, 0xc0000a05a0, 0xc006cf2d40, 0xc006cf2d58, 0x708180, 0xc001847f10, 0x203001, 0x5555555555555555, 0x38, 0xc000000180, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/scope.go:21 +0xfb
github.com/elliotchance/c2go/transpiler.transpileToStmt(0x708180, 0xc001847f10, 0xc0000a05a0, 0x0, 0x0, 0x8dd390, 0x0, 0x0, 0x8dd390, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:347 +0xcec
github.com/elliotchance/c2go/transpiler.transpileToStmts(0x708180, 0xc001847f10, 0xc0000a05a0, 0x8dd390, 0x0, 0x0, 0x0, 0x0)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:265 +0xe3
github.com/elliotchance/c2go/transpiler.transpileToBlockStmt(0x708180, 0xc001847f10, 0xc0000a05a0, 0xa, 0xc008c5f958, 0xc001fb9b01, 0x1, 0x1, 0x0, 0x0, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/scope.go:38 +0x49
github.com/elliotchance/c2go/transpiler.transpileFunctionDecl(0xc00163d450, 0xc0000a05a0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/functions.go:86 +0x28fa
github.com/elliotchance/c2go/transpiler.transpileToNode(0x7087c0, 0xc00163d450, 0xc0000a05a0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:443 +0x44d
github.com/elliotchance/c2go/transpiler.transpileTranslationUnitDecl(0xc0000a05a0, 0xc000378120, 0xc0064c8000, 0xf9, 0x100, 0x0, 0x0)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/translation_unit.go:116 +0x17e
github.com/elliotchance/c2go/transpiler.transpileToNode(0x709340, 0xc000378120, 0xc0000a05a0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:440 +0xb81
github.com/elliotchance/c2go/transpiler.TranspileAST(0x0, 0x0, 0x6abe92, 0x4, 0xc0000a05a0, 0x709340, 0xc000378120, 0x33542, 0x33542)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/transpiler/transpiler.go:32 +0x1a2
main.Start(0x0, 0xc0000101a0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6abe92, ...)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/main.go:297 +0xf29
main.runCommand(0xc0000180b8)
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/main.go:429 +0x495
main.main()
    /home/1828_sandbox/src/the-language/core/arch/go/deps/src/github.com/elliotchance/c2go/main.go:352 +0x22
Konstantin8105 commented 5 years ago

Please try https://github.com/Konstantin8105/c4go

kroppt commented 4 years ago

Replicated with the following test program:

int main() {
    return sizeof("");
}

clang:

~ $ clang --version
clang version 10.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/10/bin