Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

defaulted and virtualized copy assignment operator fails to compile

yoshimura__masataka
882 Views

When overriding operator `=` with "default" and "virtual" fails to compile.

Without virtual, it works properly.

Error Message

icpc -std=c++17 sample.cpp
ld: /tmp/icpczIU0ix.o:(.rodata._ZTV6Entity[_ZTV6Entity]+0x10): undefined reference to `Entity::operator=(Entity const&)'

Source code

#include <iostream>
class Entity {
    public:
        Entity() = default;
        virtual Entity & operator = ( Entity const & )=default;
    public:
        int index;
};

Entity e1 = Entity();

int main() {
    std::cout << e1.index;
    return(0);
}

Intel c++ compiler version

icpc (ICC) 19.0.5.281 20190815

gcc (GCC) 9.2.0

 

0 Kudos
1 Reply
Viet_H_Intel
Moderator
882 Views

Thanks for reporting this issue. I've filed a bug CMPLRIL0-32275 to the Developer.

0 Kudos
Reply