Buffer overrun with bit-fields and value initialization - compiler bug or undefined behavior?

前端 未结 1 1413
死守一世寂寞
死守一世寂寞 2021-02-19 05:35

So, I encountered a weird bug at work when I was trying to reduce the size of a struct by using bit-fields. I managed to isolate the problem and produce a minimal version that r

1条回答
  •  鱼传尺愫
    2021-02-19 06:23

    This compiler bug is being fixed in VS 2019 16.5.

    As a workaround for those who cannot upgrade, consider replacing braces with regular parenthesis, eg replace S{...}; with S(...);. If no arguments are being supplied to the constructor, consider simply removing the braces as the object is still default-constructed this way.

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