ds1379551 2017-10-24 21:46
浏览 82
已采纳

golang编译器是否使用常量折叠?

just wondering if "go" compiler uses any sort of optimization such as constant folding.

https://en.wikipedia.org/wiki/Constant_folding

searched through google but couldn't find the answer i'm looking for.

  • 写回答

2条回答 默认 最新

  • download1323 2017-10-24 22:03
    关注

    Try to write a simple program: eg.

    package main
    
    import "fmt"
    
    func main() {
        fmt.Println(12345*1000)
    }
    

    And now compile it to assembly

    go tool compile -S examle.go
    

    And now find 12345 in the result and you will have an answer.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?