Is Visual Studio 2013 optimizing correctly in the presence of /OPT:ICF?

前端 未结 2 445
轻奢々
轻奢々 2020-12-03 13:52

I expect the following program to return 0 all of the time. However with Visual Studio 2013 (Update 4), the program exits 1 in release builds. I\'m not sure if this is a bug

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 14:20

    No, this optimization does not conform to the C++ standard. The declaration of uniqueMemLoc defines a unique object for each instance of the template, and each object has its own address.

    (If you had used a string literal, it would be a different story. The optimization would be valid in that case.)

提交回复
热议问题