Does Visual C++ support “strict aliasing”?

前端 未结 1 980
一生所求
一生所求 2021-01-04 13:48

I recently was surprised to learn that the C and C++ language standards have a \"strict aliasing\" rule. In essence, the rule prohibits variables of differing types from ref

相关标签:
1条回答
  • 2021-01-04 14:09

    "Strict aliasing" is a C++ rule restricting programs, not compilers. Since violating the rule is Undefined Behavior, no diagnostic required a compiler doesn't need to support it in any way.

    That said, Microsoft is a bit less aggressive in applying optimizations. Only last week have they announced their new optimizer assumes no signed overflow, something that GCC has assumed for a few years already. Strict aliasing is going to break a few Windows headers, so those need fixing first. (A few types act as if they contain unions, but they're not formally defined as such)

    0 讨论(0)
提交回复
热议问题