Warning, /sdk/clazy/docs/checks/README-copyable-polymorphic.md is written in an unsupported language. File is not indexed.
0001 # copyable-polymorphic 0002 0003 Finds polymorphic classes that are copyable. 0004 Classes with virtual methods are usually handled by pointer, as passing 0005 then by value would allow up-casting to the base-class and slicing off the vtable. 0006 Example: 0007 0008 ``` 0009 struct Base { 0010 virtual int getNumber() const { return 41; } 0011 }; 0012 0013 struct Derived : public Base { 0014 int getNumber() const override { return 42; } 0015 }; 0016 0017 void printNumber(Base b) 0018 { 0019 qDebug() << b.getNumber(); // Always prints 41! 0020 } 0021 0022 (...) 0023 Derived d; 0024 printNumber(d); 0025 0026 ``` 0027 0028 To fix these warnings use `Q_DISABLE_COPY` or delete the copy-ctor yourself. 0029 0030 This check supports a fixit, however you'll need to set the env var 0031 CLAZY_ACCESSSPECIFIER_NON_QOBJECT=1. It's opt-in since it involves a bit of cpu 0032 overhead and is also responsible for bug #431186