DescriptionDisable VS 2015 warning that fires on compiler-generated constructors.
C4589 fires when a derived class illegally calls the constructor for
its virtual base class. Unfortunately it fires inappropriately.
If Base has a pure-virtual function and Derived is dllexported and
derives virtually from the base class then the compiler-generated
copy constructor will illegally initialize the virtual base class.
The warning is:
warning C4589 : Constructor of abstract class 'Derived' ignores
initializer for virtual base class 'Base'
note : This diagnostic occurred in the compiler generated function
'Derived::Derived(const Derived &)'
While this warning can be potentially useful (it found bad code in
crbug.com/510497) it mostly fires inappropriately. Here is repro code:
class __declspec(dllexport) Base {
virtual void SomeFunction() = 0;
};
class __declspec(dllexport) Derived : virtual public Base {
// Deleting the assignment operator avoids the warning
//Derived(const Derived&) = delete;
// Overriding SomeFunction avoids the warning
//void SomeFunction() override {};
};
The bug has been reported.
R=thakis@chromium.org
BUG=440500
Committed: https://crrev.com/d5b9a8565675b8969dd34b6aa765adcd443b5527
Cr-Commit-Position: refs/heads/master@{#338964}
Patch Set 1 #Patch Set 2 : Improve comment. #Patch Set 3 : Added to .gn configuration and sorted. #
Messages
Total messages: 11 (1 generated)
|