“pure virtual function called” on gcc 4.4 but not on newer version or clang 3.4

后端 未结 2 520
孤街浪徒
孤街浪徒 2021-01-04 08:05

I\'ve got an MCVE which, on some of my machines crashes when compiled with g++ version 4.4.7 but does work with clang++ version 3.4.2 and g++ version 6.3.

I\'d like

2条回答
  •  执笔经年
    2021-01-04 08:27

    Though the true solution to this bug would be not to use RedHat GnuCC 4.4.7 (or any RedHat compiler...), we are temporarily stuck with this version.

    We did find an alternative: obfuscate the constructor of BaseType to the compiler hence preventing it to over-optimize it. We did it simply by defining BaseType::BaseType() in a separate translation unit.

    Doing so bypass g++ bug. We did indeed checked that both BaseType and TypeTextFix virtual table pointers were written to constructed object before calling its related constructors.

提交回复
热议问题