eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.23k stars 169 forks source link

Compiler warnings #174

Open jaques-sam opened 5 years ago

jaques-sam commented 5 years ago

It's good to know if there are some warnings generated when building with a stricter compiler option list. We compile our project using the following compiler flags:

"-std=c++11"
"-Wall"
"-pedantic"
"-Wextra"
"-ffor-scope"
"-fuse-cxa-atexit"
"-fno-default-inline"
"-fvisibility=hidden"
"-fvisibility-inlines-hidden"
"-pedantic-errors"
"-Wsign-promo"
"-Wsign-compare"
"-Wnon-virtual-dtor"
"-Wold-style-cast"
"-Woverloaded-virtual"
"-Wswitch"
"-Wswitch-default"
"-Wswitch-enum"
"-Wcast-qual"
"-Wcast-align"
"-Wuninitialized"
"-Wno-float-equal"
"-Wlogical-op"
"-Wpacked"
"-Wredundant-decls"
"-Wdisabled-optimization"
"-Wdeprecated"
"-Wempty-body"
"-Wreturn-type"
"-Wunused-variable"
"-Wno-unknown-pragmas"
"-Wformat"
"-Wunreachable-code"
"-mfpmath=sse"
"-msse2"
"-Weffc++"
"-Werror"
"-Wformat-nonliteral"
"-Wsign-conversion"

And these are the warnings generated on compilation:

fakeit.hpp:77:57: error: use of old-style cast [-Werror=old-style-cast]
             std::is_same<decltype(test(*(std::ostream *)nullptr,
                                                         ^~~~~~~
fakeit.hpp:77:57: error: use of old-style cast [-Werror=old-style-cast]
fakeit.hpp: In member function ‘virtual unsigned int fakeit::RepeatedSequence::size() const’:
fakeit.hpp:565:32: error: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
             return _s.size() * times;
                                ^~~~~
fakeit.hpp: At global scope:
fakeit.hpp:618:12: error: ‘struct fakeit::VerificationEvent’ has pointer data members [-Werror=effc++]
     struct VerificationEvent {
            ^~~~~~~~~~~~~~~~~
fakeit.hpp:618:12: error:   but does not override ‘fakeit::VerificationEvent(const fakeit::VerificationEvent&)’ [-Werror=effc++]
fakeit.hpp:618:12: error:   or ‘operator=(const fakeit::VerificationEvent&)’ [-Werror=effc++]
fakeit.hpp: In constructor ‘fakeit::VerificationEvent::VerificationEvent(fakeit::VerificationType)’:
fakeit.hpp:620:9: error: ‘fakeit::VerificationEvent::_file’ should be initialized in the member initialization list [-Werror=effc++]
         VerificationEvent(VerificationType aVerificationType) :
         ^~~~~~~~~~~~~~~~~
fakeit.hpp:620:9: error: ‘fakeit::VerificationEvent::_callingMethod’ should be initialized in the member initialization list [-Werror=effc++]
fakeit.hpp: At global scope:
fakeit.hpp:741:12: error: ‘struct fakeit::VerificationEventHandler’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct VerificationEventHandler {
            ^~~~~~~~~~~~~~~~~~~~~~~~
fakeit.hpp:747:12: error: base class ‘struct fakeit::VerificationEventHandler’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct EventHandler : public VerificationEventHandler {
            ^~~~~~~~~~~~
fakeit.hpp:747:12: error: ‘struct fakeit::EventHandler’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp:763:12: error: ‘struct fakeit::EventFormatter’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct EventFormatter {
            ^~~~~~~~~~~~~~
fakeit.hpp:780:12: error: base class ‘struct fakeit::EventHandler’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct FakeitContext : public EventHandler, protected EventFormatter {
            ^~~~~~~~~~~~~
fakeit.hpp:859:12: error: base class ‘struct fakeit::EventFormatter’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct DefaultEventFormatter : public EventFormatter {
            ^~~~~~~~~~~~~~~~~~~~~
fakeit.hpp:859:12: error: ‘struct fakeit::DefaultEventFormatter’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp: In instantiation of ‘struct fakeit::ActualInvocation<>’:
fakeit.hpp:864:55:   required from here
fakeit.hpp:351:12: error: ‘struct fakeit::ActualInvocation<>’ has pointer data members [-Werror=effc++]
     struct ActualInvocation : public Invocation {
            ^~~~~~~~~~~~~~~~
fakeit.hpp:351:12: error:   but does not override ‘fakeit::ActualInvocation<>(const fakeit::ActualInvocation<>&)’ [-Werror=effc++]
fakeit.hpp:351:12: error:   or ‘operator=(const fakeit::ActualInvocation<>&)’ [-Werror=effc++]
fakeit.hpp: In constructor ‘fakeit::FakeitException::FakeitException()’:
fakeit.hpp:988:12: error: ‘fakeit::FakeitException::err’ should be initialized in the member initialization list [-Werror=effc++]
     struct FakeitException {
            ^~~~~~~~~~~~~~~
fakeit.hpp: In constructor ‘fakeit::UnexpectedMethodCallException::UnexpectedMethodCallException(std::__cxx11::string)’:
fakeit.hpp:1007:31: note: synthesized method ‘fakeit::FakeitException::FakeitException()’ first required here
                 _format(format) {
                               ^
fakeit.hpp: At global scope:
fakeit.hpp:1022:12: error: base class ‘struct fakeit::EventHandler’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct DefaultEventLogger : public fakeit::EventHandler {
            ^~~~~~~~~~~~~~~~~~
fakeit.hpp:1022:12: error: ‘struct fakeit::DefaultEventLogger’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp:1058:11: error: ‘class fakeit::DefaultFakeit’ has pointer data members [-Werror=effc++]
     class DefaultFakeit : public AbstractFakeit {
           ^~~~~~~~~~~~~
fakeit.hpp:1058:11: error:   but does not override ‘fakeit::DefaultFakeit(const fakeit::DefaultFakeit&)’ [-Werror=effc++]
fakeit.hpp:1058:11: error:   or ‘operator=(const fakeit::DefaultFakeit&)’ [-Werror=effc++]
fakeit.hpp: In constructor ‘fakeit::FakeitContext::FakeitContext()’:
fakeit.hpp:780:12: error: ‘fakeit::FakeitContext::_eventListeners’ should be initialized in the member initialization list [-Werror=effc++]
     struct FakeitContext : public EventHandler, protected EventFormatter {
            ^~~~~~~~~~~~~
fakeit.hpp: In constructor ‘fakeit::AbstractFakeit::AbstractFakeit()’:
fakeit.hpp:1047:11: note: synthesized method ‘fakeit::FakeitContext::FakeitContext()’ first required here
     class AbstractFakeit : public FakeitContext {
           ^~~~~~~~~~~~~~
fakeit.hpp: In constructor ‘fakeit::DefaultFakeit::DefaultFakeit()’:
fakeit.hpp:1067:59: note: synthesized method ‘fakeit::AbstractFakeit::AbstractFakeit()’ first required here
                           _testingFrameworkAdapter(nullptr) {
                                                           ^
fakeit.hpp: At global scope:
fakeit.hpp:1111:7: error: base class ‘struct fakeit::EventHandler’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
 class QTestAdapter: public EventHandler {
       ^~~~~~~~~~~~
fakeit.hpp:1190:12: error: ‘struct fakeit::VirtualOffsetSelector’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct VirtualOffsetSelector {
            ^~~~~~~~~~~~~~~~~~~~~
fakeit.hpp: In static member function ‘static fakeit::VirtualTableBase& fakeit::VirtualTableBase::getVTable(void*)’:
fakeit.hpp:5577:82: error: use of old-style cast [-Werror=old-style-cast]
             fakeit::VirtualTableBase *vt = (fakeit::VirtualTableBase *) (instance);
                                                                                  ^
fakeit.hpp: In member function ‘fakeit::VirtualTable<C, baseclasses>& fakeit::VirtualTable<C, baseclasses>::Handle::restore()’:
fakeit.hpp:5622:91: error: use of old-style cast [-Werror=old-style-cast]
                 VirtualTable<C, baseclasses...> *vt = (VirtualTable<C, baseclasses...> *) this;
                                                                                           ^~~~
fakeit.hpp: In static member function ‘static fakeit::VirtualTable<C, baseclasses>& fakeit::VirtualTable<C, baseclasses>::getVTable(C&)’:
fakeit.hpp:5628:113: error: use of old-style cast [-Werror=old-style-cast]
             fakeit::VirtualTable<C, baseclasses...> *vt = (fakeit::VirtualTable<C, baseclasses...> *) (&instance);
                                                                                                                 ^
fakeit.hpp: In member function ‘unsigned int fakeit::VirtualTable<C, baseclasses>::dtor(int)’:
fakeit.hpp:5652:26: error: use of old-style cast [-Werror=old-style-cast]
             C *c = (C *) this;
                          ^~~~
fakeit.hpp: In member function ‘const std::type_info* fakeit::VirtualTable<C, baseclasses>::getTypeId()’:
fakeit.hpp:5686:62: error: use of old-style cast [-Werror=old-style-cast]
             return (const std::type_info *) (_firstMethod[-1]);
                                                              ^
fakeit.hpp: In member function ‘void fakeit::FakeObject<C, baseclasses>::initializeDataMembersArea()’:
fakeit.hpp:5763:72: error: use of old-style cast [-Werror=old-style-cast]
             for (size_t i = 0; i < SIZE; ++i) instanceArea[i] = (char) 0;
                                                                        ^
fakeit.hpp: At global scope:
fakeit.hpp:5827:12: error: ‘struct fakeit::InvocationHandlerCollection’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct InvocationHandlerCollection {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
fakeit.hpp: In static member function ‘static fakeit::InvocationHandlerCollection* fakeit::InvocationHandlerCollection::getInvocationHandlerCollection(void*)’:
fakeit.hpp:5835:65: error: use of old-style cast [-Werror=old-style-cast]
                     InvocationHandlerCollection::VT_COOKIE_INDEX);
                                                                 ^
fakeit.hpp: In member function ‘R fakeit::MethodProxyCreator<R, arglist>::methodProxy(unsigned int, const typename fakeit::production_arg<arglist>::type ...)’:
fakeit.hpp:5860:31: error: use of old-style cast [-Werror=old-style-cast]
                             id);
                               ^
fakeit.hpp: At global scope:
fakeit.hpp:5873:11: error: base class ‘struct fakeit::InvocationHandlerCollection’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     class InvocationHandlers : public InvocationHandlerCollection {
           ^~~~~~~~~~~~~~~~~~
fakeit.hpp:5873:11: error: ‘class fakeit::InvocationHandlers’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp: In constructor ‘fakeit::InvocationHandlers::InvocationHandlers(std::vector<std::shared_ptr<fakeit::Destructible> >&, std::vector<unsigned int, std::allocator<unsigned int> >&)’:
fakeit.hpp:5895:40: error: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
     *it = std::numeric_limits<int>::max();
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
fakeit.hpp: In member function ‘void fakeit::DynamicProxy<C, baseclasses>::stubDataMember(DATA_TYPE C::*, const arglist& ...)’:
fakeit.hpp:5987:56: error: use of old-style cast [-Werror=old-style-cast]
             DATA_TYPE C::*theMember = (DATA_TYPE C::*) member;
                                                        ^~~~~~
fakeit.hpp: In member function ‘void fakeit::DynamicProxy<C, baseclasses>::checkMultipleInheritance()’:
fakeit.hpp:6064:43: error: use of old-style cast [-Werror=old-style-cast]
             C *ptr = (C *) (unsigned int) 1;
                                           ^
fakeit.hpp:6064:43: error: use of old-style cast [-Werror=old-style-cast]
fakeit.hpp:6066:41: error: use of old-style cast [-Werror=old-style-cast]
             int delta = (unsigned long) basePtr - (unsigned long) ptr;
                                         ^~~~~~~
fakeit.hpp:6066:67: error: use of old-style cast [-Werror=old-style-cast]
             int delta = (unsigned long) basePtr - (unsigned long) ptr;
                                                                   ^~~
fakeit.hpp: In function ‘fakeit::QuantifierFunctor fakeit::operator""_Times(long long unsigned int)’:
fakeit.hpp:6956:40: error: use of old-style cast [-Werror=old-style-cast]
         return QuantifierFunctor((int) n);
                                        ^
fakeit.hpp: In function ‘fakeit::QuantifierFunctor fakeit::operator""_Time(long long unsigned int)’:
fakeit.hpp:6965:40: error: use of old-style cast [-Werror=old-style-cast]
         return QuantifierFunctor((int) n);
                                        ^
fakeit.hpp: At global scope:
fakeit.hpp:7357:42: error: ‘operator=’ should return a reference to ‘*this’ [-Werror=effc++]
         void operator=(const DATA_TYPE&) {
                                          ^
fakeit.hpp:7374:12: error: ‘struct fakeit::Xaction’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct Xaction {
            ^~~~~~~
fakeit.hpp:7754:63: error: ‘operator=’ should return a reference to ‘*this’ [-Werror=effc++]
         void operator=(std::function<R(arglist &...)> method) {
                                                               ^
fakeit.hpp:7819:66: error: ‘operator=’ should return a reference to ‘*this’ [-Werror=effc++]
         void operator=(std::function<void(arglist &...)> method) {
                                                                  ^
fakeit.hpp: In instantiation of ‘struct fakeit::StubbingContext<void>’:
fakeit.hpp:7492:11:   required from ‘class fakeit::MethodMockingContext<void>’
fakeit.hpp:7825:39:   required from here
fakeit.hpp:7393:12: error: base class ‘struct fakeit::Xaction’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct StubbingContext : public Xaction {
            ^~~~~~~~~~~~~~~
fakeit.hpp:7393:12: error: ‘struct fakeit::StubbingContext<void>’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp: In instantiation of ‘struct fakeit::SpyingContext<void>’:
fakeit.hpp:7492:11:   required from ‘class fakeit::MethodMockingContext<void>’
fakeit.hpp:7825:39:   required from here
fakeit.hpp:7383:12: error: base class ‘struct fakeit::Xaction’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct SpyingContext : Xaction {
            ^~~~~~~~~~~~~
fakeit.hpp:7383:12: error: ‘struct fakeit::SpyingContext<void>’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp: In instantiation of ‘class fakeit::MethodMockingContext<void>’:
fakeit.hpp:7825:39:   required from here
fakeit.hpp:7492:11: error: base class ‘struct fakeit::StubbingContext<void>’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     class MethodMockingContext :
           ^~~~~~~~~~~~~~~~~~~~
fakeit.hpp:7492:11: error: base class ‘struct fakeit::SpyingContext<void>’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp:7838:54: error: ‘operator=’ should return a reference to ‘*this’ [-Werror=effc++]
         void operator=(std::function<void()> method) {
                                                      ^
fakeit.hpp: In static member function ‘static bool fakeit::MatchAnalysis::findNextMatch(std::vector<fakeit::Sequence*>&, std::vector<fakeit::Invocation*>&, int, int&, std::vector<fakeit::Invocation*>&)’:
fakeit.hpp:8594:100: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion]
                 collectMatchedInvocations(actualSequence, matchedInvocations, index, sequence->size());
                                                                                      ~~~~~~~~~~~~~~^~
fakeit.hpp:8595:59: error: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
                 startSearchIndex = index + sequence->size();
                                                           ^
fakeit.hpp:8595:42: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion]
                 startSearchIndex = index + sequence->size();
                                    ~~~~~~^~~~~~~~~~~~~~~~~~
fakeit.hpp: In static member function ‘static void fakeit::MatchAnalysis::collectMatchedInvocations(std::vector<fakeit::Invocation*>&, std::vector<fakeit::Invocation*>&, int, int)’:
fakeit.hpp:8607:66: error: conversion to ‘std::vector<fakeit::Invocation*>::size_type {aka long unsigned int}’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
                 matchedInvocations.push_back(actualSequence[start]);
                                                                  ^
fakeit.hpp: In static member function ‘static bool fakeit::MatchAnalysis::isMatch(std::vector<fakeit::Invocation*>&, std::vector<fakeit::Invocation::Matcher*>&, int)’:
fakeit.hpp:8616:61: error: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
                 Invocation *actual = actualSequence[start + j];
                                                             ^
fakeit.hpp: In static member function ‘static int fakeit::MatchAnalysis::findNextMatch(fakeit::Sequence*&, std::vector<fakeit::Invocation*>&, int)’:
fakeit.hpp:8626:75: error: use of old-style cast [-Werror=old-style-cast]
             for (int i = startSearchIndex; i < ((int) actualSequence.size() - (int) expectedSequence.size() + 1); i++) {
                                                                           ^
fakeit.hpp:8626:107: error: use of old-style cast [-Werror=old-style-cast]
             for (int i = startSearchIndex; i < ((int) actualSequence.size() - (int) expectedSequence.size() + 1); i++) {
                                                                                                           ^
fakeit.hpp: At global scope:
fakeit.hpp:8639:12: error: ‘struct fakeit::SequenceVerificationExpectation’ has pointer data members [-Werror=effc++]
     struct SequenceVerificationExpectation {
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fakeit.hpp:8639:12: error:   but does not override ‘fakeit::SequenceVerificationExpectation(const fakeit::SequenceVerificationExpectation&)’ [-Werror=effc++]
fakeit.hpp:8639:12: error:   or ‘operator=(const fakeit::SequenceVerificationExpectation&)’ [-Werror=effc++]
fakeit.hpp: In constructor ‘fakeit::SequenceVerificationExpectation::SequenceVerificationExpectation(fakeit::VerificationEventHandler&, fakeit::InvocationsSourceProxy, std::vector<fakeit::Sequence*>&)’:
fakeit.hpp:8676:9: error: ‘fakeit::SequenceVerificationExpectation::_file’ should be initialized in the member initialization list [-Werror=effc++]
         SequenceVerificationExpectation(
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fakeit.hpp:8676:9: error: ‘fakeit::SequenceVerificationExpectation::_testMethod’ should be initialized in the member initialization list [-Werror=effc++]
fakeit.hpp: In constructor ‘fakeit::MatchAnalysis::MatchAnalysis()’:
fakeit.hpp:8551:12: error: ‘fakeit::MatchAnalysis::actualSequence’ should be initialized in the member initialization list [-Werror=effc++]
     struct MatchAnalysis {
            ^~~~~~~~~~~~~
fakeit.hpp:8551:12: error: ‘fakeit::MatchAnalysis::matchedInvocations’ should be initialized in the member initialization list [-Werror=effc++]
fakeit.hpp:8551:12: error: ‘fakeit::MatchAnalysis::count’ should be initialized in the member initialization list [-Werror=effc++]
fakeit.hpp: In member function ‘void fakeit::SequenceVerificationExpectation::VerifyExpectation(fakeit::VerificationEventHandler&)’:
fakeit.hpp:8694:27: note: synthesized method ‘fakeit::MatchAnalysis::MatchAnalysis()’ first required here
             MatchAnalysis ma;
                           ^~
fakeit.hpp: At global scope:
fakeit.hpp:8763:11: error: base class ‘struct fakeit::VerificationEventHandler’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     class ThrowFalseEventHandler : public VerificationEventHandler {
           ^~~~~~~~~~~~~~~~~~~~~~
fakeit.hpp:8763:11: error: ‘class fakeit::ThrowFalseEventHandler’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp:8794:11: error: ‘class fakeit::SequenceVerificationProgress’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
     class SequenceVerificationProgress {
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
fakeit.hpp:9001:16: error: ‘struct fakeit::VerifyNoOtherInvocationsVerificationProgress::VerifyNoOtherInvocationsExpectation’ has pointer data members [-Werror=effc++]
         struct VerifyNoOtherInvocationsExpectation {
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fakeit.hpp:9001:16: error:   but does not override ‘operator=(const fakeit::VerifyNoOtherInvocationsVerificationProgress::VerifyNoOtherInvocationsExpectation&)’ [-Werror=effc++]
fakeit.hpp: In constructor ‘fakeit::VerifyNoOtherInvocationsVerificationProgress::VerifyNoOtherInvocationsExpectation::VerifyNoOtherInvocationsExpectation(fakeit::VerificationEventHandler&, std::vector<fakeit::ActualInvocationsSource*>)’:
fakeit.hpp:9029:13: error: ‘fakeit::VerifyNoOtherInvocationsVerificationProgress::VerifyNoOtherInvocationsExpectation::_file’ should be initialized in the member initialization list [-Werror=effc++]
             VerifyNoOtherInvocationsExpectation(VerificationEventHandler &fakeit,
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fakeit.hpp:9029:13: error: ‘fakeit::VerifyNoOtherInvocationsVerificationProgress::VerifyNoOtherInvocationsExpectation::_callingMethod’ should be initialized in the member initialization list [-Werror=effc++]
In file included
     virtual void testQObjectCast() = 0 {};
                                    ^
fakeit.hpp: In instantiation of ‘struct fakeit::StubbingContext<bool>’:
fakeit.hpp:7492:11:   required from ��class fakeit::MethodMockingContext<bool>’
fakeit.hpp:7707:11:   required from ‘class fakeit::MockingContext<bool>’
fakeit.hpp:7393:12: error: base class ‘struct fakeit::Xaction’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct StubbingContext : public Xaction {
            ^~~~~~~~~~~~~~~
fakeit.hpp:7393:12: error: ‘struct fakeit::StubbingContext<bool>’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp: In instantiation of ‘struct fakeit::SpyingContext<bool>’:
fakeit.hpp:7492:11:   required from ‘class fakeit::MethodMockingContext<bool>’
fakeit.hpp:7707:11:   required from ‘class fakeit::MockingContext<bool>’
fakeit.hpp:7383:12: error: base class ‘struct fakeit::Xaction’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct SpyingContext : Xaction {
            ^~~~~~~~~~~~~
fakeit.hpp:7383:12: error: ‘struct fakeit::SpyingContext<bool>’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp: In instantiation of ‘class fakeit::MethodMockingContext<bool>’:
fakeit.hpp:7707:11:   required from ‘class fakeit::MockingContext<bool>’
fakeit.hpp:7492:11: error: base class ‘struct fakeit::StubbingContext<bool>’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     class MethodMockingContext :
           ^~~~~~~~~~~~~~~~~~~~
fakeit.hpp:7492:11: error: base class ‘struct fakeit::SpyingContext<bool>’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp: In instantiation of ‘struct fakeit::StubbingContext<const QString&>’:
fakeit.hpp:7492:11:   required from ‘class fakeit::MethodMockingContext<const QString&>’
fakeit.hpp:7707:11:   required from ‘class fakeit::MockingContext<const QString&>’
fakeit.hpp:7393:12: error: base class ‘struct fakeit::Xaction’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct StubbingContext : public Xaction {
            ^~~~~~~~~~~~~~~
fakeit.hpp:7393:12: error: ‘struct fakeit::StubbingContext<const QString&>’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp: In instantiation of ‘struct fakeit::SpyingContext<const QString&>’:
fakeit.hpp:7492:11:   required from ‘class fakeit::MethodMockingContext<const QString&>’
fakeit.hpp:7707:11:   required from ‘class fakeit::MockingContext<const QString&>’
fakeit.hpp:7383:12: error: base class ‘struct fakeit::Xaction’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     struct SpyingContext : Xaction {
            ^~~~~~~~~~~~~
fakeit.hpp:7383:12: error: ‘struct fakeit::SpyingContext<const QString&>’ has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp: In instantiation of ‘class fakeit::MethodMockingContext<const QString&>’:
fakeit.hpp:7707:11:   required from ‘class fakeit::MockingContext<const QString&>’
fakeit.hpp:7492:11: error: base class ‘struct fakeit::StubbingContext<const QString&>’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
     class MethodMockingContext :
           ^~~~~~~~~~~~~~~~~~~~
fakeit.hpp:7492:11: error: base class ‘struct fakeit::SpyingContext<const QString&>’ has accessible non-virtual destructor [-Werror=non-virtual-dtor]
fakeit.hpp: In instantiation of ‘class fakeit::MethodMockingContext<void>::Implementation’:
fakeit.hpp:7615:25:   required from ‘fakeit::MethodMockingContext<R, arglist>::MethodMockingContext(fakeit::MethodMockingContext<R, arglist>::Context*) [with R = void; arglist = {}]’
fakeit.hpp:7829:61:   required from here
fakeit.hpp:7520:15: error: ‘class fakeit::MethodMockingContext<void>::Implementation’ has pointer data members [-Werror=effc++]
         class Implementation {
               ^~~~~~~~~~~~~~
fakeit.hpp:7520:15: error:   but does not override ‘fakeit::MethodMockingContext<void>::Implementation(const fakeit::MethodMockingContext<void>::Implementation&)’ [-Werror=effc++]
fakeit.hpp:7520:15: error:   or ‘operator=(const fakeit::MethodMockingContext<void>::Implementation&)’ [-Werror=effc++]
fakeit.hpp: In instantiation of ‘class fakeit::MethodMockingContext<bool>::Implementation’:
fakeit.hpp:7662:20:   required from ‘void fakeit::MethodMockingContext<R, arglist>::setMethodDetails(std::__cxx11::string, std::__cxx11::string) [with R = bool; arglist = {}; std::__cxx11::string = std::__cxx11::basic_string<char>]’
fakeit.hpp:7724:66:   required from ‘fakeit::MockingContext<R, arglist>& fakeit::MockingContext<R, arglist>::setMethodDetails(std::__cxx11::string, std::__cxx11::string) [with R = bool; arglist = {}; std::__cxx11::string = std::__cxx11::basic_string<char>]’
fakeit.hpp:7520:15: error: ‘class fakeit::MethodMockingContext<bool>::Implementation’ has pointer data members [-Werror=effc++]
fakeit.hpp:7520:15: error:   but does not override ‘fakeit::MethodMockingContext<bool>::Implementation(const fakeit::MethodMockingContext<bool>::Implementation&)’ [-Werror=effc++]
fakeit.hpp:7520:15: error:   or ‘operator=(const fakeit::MethodMockingContext<bool>::Implementation&)’ [-Werror=effc++]
fakeit.hpp: In instantiation of ‘class fakeit::MethodMockingContext<const QString&>::Implementation’:
fakeit.hpp:7662:20:   required from ‘void fakeit::MethodMockingContext<R, arglist>::setMethodDetails(std::__cxx11::string, std::__cxx11::string) [with R = const QString&; arglist = {}; std::__cxx11::string = std::__cxx11::basic_string<char>]’
fakeit.hpp:7724:66:   required from ‘fakeit::MockingContext<R, arglist>& fakeit::MockingContext<R, arglist>::setMethodDetails(std::__cxx11::string, std::__cxx11::string) [with R = const QString&; arglist = {}; std::__cxx11::string = std::__cxx11::basic_string<char>]’
fakeit.hpp:7520:15: error: ‘class fakeit::MethodMockingContext<const QString&>::Implementation’ has pointer data members [-Werror=effc++]
fakeit.hpp:7520:15: error:   but does not override ‘fakeit::MethodMockingContext<const QString&>::Implementation(const fakeit::MethodMockingContext<const QString&>::Implementation&)’ [-Werror=effc++]
fakeit.hpp:7520:15: error:   or ‘operator=(const fakeit::MethodMockingContext<const QString&>::Implementation&)’ [-Werror=effc++]
fakeit.hpp: In instantiation of ‘fakeit::ActionSequence<R, arglist>::ActionSequence() [with R = void; arglist = {}]’:
fakeit.hpp:7535:47:   required from ‘fakeit::MethodMockingContext<R, arglist>::Implementation::Implementation(fakeit::MethodMockingContext<R, arglist>::Context*) [with R = void; arglist = {}]’
fakeit.hpp:7615:25:   required from ‘fakeit::MethodMockingContext<R, arglist>::MethodMockingContext(fakeit::MethodMockingContext<R, arglist>::Context*) [with R = void; arglist = {}]’
fakeit.hpp:7829:61:   required from here
fakeit.hpp:7290:9: error: ‘fakeit::ActionSequence<void>::_recordedActions’ should be initialized in the member initialization list [-Werror=effc++]
         ActionSequence() {
         ^~~~~~~~~~~~~~
fakeit.hpp: In instantiation of ‘fakeit::DynamicProxy<C, baseclasses>::DynamicProxy(C&) [with C = Foo; baseclasses = {}]’:
fakeit.hpp:7950:21:   required from ‘fakeit::MockImpl<C, baseclasses>::MockImpl(fakeit::FakeitContext&, C&, bool) [with C = Foo; baseclasses = {}]’
fakeit.hpp:7862:85:   required from ‘fakeit::MockImpl<C, baseclasses>::MockImpl(fakeit::FakeitContext&) [with C = Foo; baseclasses = {}]’
fakeit.hpp:8200:29:   required from ‘fakeit::Mock<C, baseclasses>::Mock() [with C = Foo; baseclasses = {}]’
fakeit.hpp:5912:9: error: ‘fakeit::DynamicProxy<Foo>::_cloneVt’ should be initialized in the member initialization list [-Werror=effc++]
         DynamicProxy(C &inst) :
         ^~~~~~~~~~~~
fakeit.hpp:5912:9: error: ‘fakeit::DynamicProxy<Foo>::_members’ should be initialized in the member initialization list [-Werror=effc++]
fakeit.hpp: In instantiation of ‘static unsigned int fakeit::VTUtils::getOffset(R (C::*)(arglist ...)) [with C = fakeit::VTUtils::getVTSize() [with C = Foo]::Derrived; R = void; arglist = {}]’:
fakeit.hpp:5272:44:   required from ‘static unsigned int fakeit::VTUtils::getVTSize() [with C = Foo]’
fakeit.hpp:5937:54:   required from ‘void fakeit::DynamicProxy<C, baseclasses>::Reset() [with C = Foo; baseclasses = {}]’
fakeit.hpp:7889:13:   required from ‘void fakeit::MockImpl<C, baseclasses>::reset() [with C = Foo; baseclasses = {}]’
fakeit.hpp:8219:13:   required from ‘void fakeit::Mock<C, baseclasses>::Reset() [with C = Foo; baseclasses = {}]’
fakeit.hpp:1190:12: error: ‘fakeit::VirtualOffsetSelector::offset’ should be initialized in the member initialization list [-Werror=effc++]
     struct VirtualOffsetSelector {
            ^~~~~~~~~~~~~~~~~~~~~
fakeit.hpp:5235:35: note: synthesized method ‘fakeit::VirtualOffsetSelector::VirtualOffsetSelector()’ first required here
             VirtualOffsetSelector offsetSelctor;
                                   ^~~~~~~~~~~~~
fakeit.hpp: In instantiation of ‘static void** fakeit::VirtualTable<C, baseclasses>::buildVTArray() [with C = Foo; baseclasses = {}]’:
fakeit.hpp:5641:42:   required from ‘fakeit::VirtualTable<C, baseclasses>::VirtualTable() [with C = Foo; baseclasses = {}]’
fakeit.hpp:5754:31:   required from ‘fakeit::FakeObject<C, baseclasses>::FakeObject() [with C = Foo; baseclasses = {}]’
fakeit.hpp:8084:51:   required from ‘static C* fakeit::MockImpl<C, baseclasses>::createFakeInstance() [with C = Foo; baseclasses = {}]’
fakeit.hpp:7862:75:   required from ‘fakeit::MockImpl<C, baseclasses>::MockImpl(fakeit::FakeitContext&) [with C = Foo; baseclasses = {}]’
fakeit.hpp:8200:29:   required from ‘fakeit::Mock<C, baseclasses>::Mock() [with C = Foo; baseclasses = {}]’
fakeit.hpp:5698:45: error: conversion to ‘int’ from ‘unsigned int’ may change the sign of the result [-Werror=sign-conversion]
             int size = VTUtils::getVTSize<C>();
                        ~~~~~~~~~~~~~~~~~~~~~^~
fakeit.hpp:5699:42: error: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
             auto array = new void *[size + 2 + numOfCookies]{};
                                     ~~~~~^~~
fakeit.hpp: In instantiation of ‘fakeit::ActionSequence<R, arglist>::ActionSequence() [with R = bool; arglist = {}]’:
fakeit.hpp:7535:47:   required from ‘fakeit::MethodMockingContext<R, arglist>::Implementation::Implementation(fakeit::MethodMockingContext<R, arglist>::Context*) [with R = bool; arglist = {}]’
fakeit.hpp:7615:25:   required from ‘fakeit::MethodMockingContext<R, arglist>::MethodMockingContext(fakeit::MethodMockingContext<R, arglist>::Context*) [with R = bool; arglist = {}]’
fakeit.hpp:7714:70:   required from ‘fakeit::MockingContext<R, arglist>::MockingContext(typename fakeit::MethodMockingContext<R, arglist ...>::Context*) [with R = bool; arglist = {}; typename fakeit::MethodMockingContext<R, arglist ...>::Context = fakeit::MethodMockingContext<bool>::Context]’
fakeit.hpp:7919:20:   required from ‘fakeit::MockingContext<R, arglist ...> fakeit::MockImpl<C, baseclasses>::stubMethod(R (T::*)(arglist ...)) [with int id = 0; R = bool; T = Protocol; arglist = {}; <template-parameter-2-5> = void; C = Foo; baseclasses = {}]’
fakeit.hpp:8236:75:   required from ‘fakeit::MockingContext<R, arglist ...> fakeit::Mock<C, baseclasses>::stub(R (T::*)(arglist ...) const) [with int id = 0; R = bool; T = Protocol; arglist = {}; <template-parameter-2-5> = void; C = Foo; baseclasses = {}]’
fakeit.hpp:7290:9: error: ‘fakeit::ActionSequence<bool>::_recordedActions’ should be initialized in the member initialization list [-Werror=effc++]
         ActionSequence() {
         ^~~~~~~~~~~~~~
fakeit.hpp: In instantiation of ‘fakeit::ActionSequence<R, arglist>::ActionSequence() [with R = const QString&; arglist = {}]’:
fakeit.hpp:7535:47:   required from ‘fakeit::MethodMockingContext<R, arglist>::Implementation::Implementation(fakeit::MethodMockingContext<R, arglist>::Context*) [with R = const QString&; arglist = {}]’
fakeit.hpp:7615:25:   required from ‘fakeit::MethodMockingContext<R, arglist>::MethodMockingContext(fakeit::MethodMockingContext<R, arglist>::Context*) [with R = const QString&; arglist = {}]’
fakeit.hpp:7714:70:   required from ‘fakeit::MockingContext<R, arglist>::MockingContext(typename fakeit::MethodMockingContext<R, arglist ...>::Context*) [with R = const QString&; arglist = {}; typename fakeit::MethodMockingContext<R, arglist ...>::Context = fakeit::MethodMockingContext<const QString&>::Context]’
fakeit.hpp:7919:20:   required from ‘fakeit::MockingContext<R, arglist ...> fakeit::MockImpl<C, baseclasses>::stubMethod(R (T::*)(arglist ...)) [with int id = 1; R = const QString&; T = Protocol; arglist = {}; <template-parameter-2-5> = void; C = Foo; baseclasses = {}]’
fakeit.hpp:8236:75:   required from ‘fakeit::MockingContext<R, arglist ...> fakeit::Mock<C, baseclasses>::stub(R (T::*)(arglist ...) const) [with int id = 1; R = const QString&; T = Protocol; arglist = {}; <template-parameter-2-5> = void; C = Foo; baseclasses = {}]’
fakeit.hpp:7290:9: error: ‘fakeit::ActionSequence<const QString&>::_recordedActions’ should be initialized in the member initialization list [-Werror=effc++]
fakeit.hpp: In instantiation of ‘fakeit::RecordedMethodBody<R, arglist>::RecordedMethodBody(fakeit::FakeitContext&, std::__cxx11::string) [with R = const QString&; arglist = {}; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
fakeit.hpp:8131:20:   required from ‘static fakeit::RecordedMethodBody<R, arglist ...>* fakeit::MockImpl<C, baseclasses>::createRecordedMethodBody(fakeit::MockObject<C>&, R (C::*)(arglist ...)) [with R = const QString&; arglist = {}; C = Foo; baseclasses = {}]’
fakeit.hpp:8112:99:   required from ‘fakeit::RecordedMethodBody<R, arglist ...>& fakeit::MockImpl<C, baseclasses>::stubMethodIfNotStubbed(fakeit::DynamicProxy<C, baseclasses ...>&, R (C::*)(arglist ...)) [with unsigned int id = 1u; R = const QString&; arglist = {}; C = Foo; baseclasses = {}]’
fakeit.hpp:8027:74:   required from ‘fakeit::RecordedMethodBody<R, arglist ...>& fakeit::MockImpl<C, baseclasses>::UniqueMethodMockingContextImpl<id, R, arglist>::getRecordedMethodBody() [with int id = 1; R = const QString&; arglist = {}; C = Foo; baseclasses = {}]’
fakeit.hpp:6812:9: error: ‘fakeit::RecordedMethodBody<const QString&>::_invocationHandlers’ should be initialized in the member initialization list [-Werror=effc++]
         RecordedMethodBody(FakeitContext &fakeit, std::string name) :
         ^~~~~~~~~~~~~~~~~~
fakeit.hpp:6812:9: error: ‘fakeit::RecordedMethodBody<const QString&>::_actualInvocations’ should be initialized in the member initialization list [-Werror=effc++]
fakeit.hpp: In instantiation of ‘fakeit::RecordedMethodBody<R, arglist>::RecordedMethodBody(fakeit::FakeitContext&, std::__cxx11::string) [with R = bool; arglist = {}; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
fakeit.hpp:8131:20:   required from ‘static fakeit::RecordedMethodBody<R, arglist ...>* fakeit::MockImpl<C, baseclasses>::createRecordedMethodBody(fakeit::MockObject<C>&, R (C::*)(arglist ...)) [with R = bool; arglist = {}; C = Foo; baseclasses = {}]’
fakeit.hpp:8112:99:   required from ‘fakeit::RecordedMethodBody<R, arglist ...>& fakeit::MockImpl<C, baseclasses>::stubMethodIfNotStubbed(fakeit::DynamicProxy<C, baseclasses ...>&, R (C::*)(arglist ...)) [with unsigned int id = 0u; R = bool; arglist = {}; C = Foo; baseclasses = {}]’
fakeit.hpp:8027:74:   required from ‘fakeit::RecordedMethodBody<R, arglist ...>& fakeit::MockImpl<C, baseclasses>::UniqueMethodMockingContextImpl<id, R, arglist>::getRecordedMethodBody() [with int id = 0; R = bool; arglist = {}; C = Foo; baseclasses = {}]’
fakeit.hpp:6812:9: error: ‘fakeit::RecordedMethodBody<bool>::_invocationHandlers’ should be initialized in the member initialization list [-Werror=effc++]
fakeit.hpp:6812:9: error: ‘fakeit::RecordedMethodBody<bool>::_actualInvocations’ should be initialized in the member initialization list [-Werror=effc++]

Some of these warnings could be ignored (like -Weffc++), some could really cause bugs. I'm convinced that solving most of them would solve some open issues.

jaques-sam commented 5 years ago

The header we are using is the QTest fakeit.hpp. After analysing which compiler options are violated, these are the ones:

-Werror=effc+
-Werror=non-virtual-dtor
-Werror=old-style-cast
-Werror=sign-conversion