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

后端 未结 2 523
孤街浪徒
孤街浪徒 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

    This is a Red Hat-specific bug not present in FSF GCC. It is not a problem in your code.

    On a system with both CentOS 6's GCC, and FSF GCC 4.4.7, having both generate an assembly listing and viewing the differences between the two, one bit jumps out:

    CentOS 6's GCC generates

    movq $_ZTV8BaseType+16, (%rsp)
    

    whereas FSF GCC 4.4.7 generates

    movq $_ZTV11TypeTextFix+16, (%rsp)
    

    In other words, one of Red Hat's GCC patches makes it set up the vtable incorrectly. This is part of your main function, you can see it in your own assembly listing shortly after .L48:.

    Red Hat applies many patches to its version of GCC, and some of them are patches that affect code generation. Unfortunately, one of them appears to have an unintended side effect.

提交回复
热议问题