Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
234 Views

defaulted and virtualized copy assignment operator fails to compile

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
Highlighted
Moderator
234 Views

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

0 Kudos