User Activity

  • Posted a comment on discussion General Discussion on cppcheck

    With the following code when there is failure to allocate memory std::bad_alloc is thrown. The following test of the pointer is useless. This is from C++ Gotchas P172. I think it would be worthwhile to catch this with CPPCheck. int * ip = new int; if (ip) std::cout << "Always executed"; else std::cout << "Never executed";

  • Posted a comment on discussion General Discussion on cppcheck

    There is public inheritance of base classes A, B and D. The reference of C converts implicitly to a reference of A, B and D. The same warning also occurs with move assignment operators.

  • Posted a comment on discussion General Discussion on cppcheck

    The warning 'Access of moved variable other' comes up quite frequently when the code is ok. It occurs with move constructors when there are base classes. Could this be fixed? E.g; C::C(C &&other) noexcept : A(std::move(other)), B(std::move(other)), D(std::move(other)) { }

  • Posted a comment on discussion General Discussion on cppcheck

    My objects that are created and destroyed in one statement always do something required and it is often quite a lot. I've found it can be easier to debug when the debugger can use an identifier and there are more statements to put breakpoints on. Your example is probably an exceptional case and it given at C++ Core Guidelines somewhere.

  • Posted a comment on discussion General Discussion on cppcheck

    I have some objects without names that are created and destroyed with one statement. This minimises the objects lifetime. CPPCheck tells me "Instance of 'xxx' object is destroyed immediately." as a style warning. I see this as good style.

  • Posted a comment on discussion General Discussion on cppcheck

    I find that many potentialy inlined functions are defined in a .cpp file and called from another translation unit.

  • Posted a comment on discussion General Discussion on cppcheck

    I can't see a negative side to it other than too much inlining. Someone thought it was worthwhile making constexpr functions implicitly declared inline.

  • Posted a comment on discussion General Discussion on cppcheck

    To use inline on small functions is recommended by C++ Core Guidelines F5. It says inline isn't required for function templates but unless they are defined within a class definition they are not inplicitly declared inline.

View All

Personal Data

Username:
fraserross
Joined:
2009-07-27 17:04:35

Projects

  • No projects to display.

Personal Tools