function2 icon indicating copy to clipboard operation
function2 copied to clipboard

Some compiler warnings are generated

Open hadrielk opened this issue 6 years ago • 1 comments

@Naios

This is relatively minor, but I thought I'd mention it before I forget about them: building function2 strictly as a copied header with clang can trigger a few warnings, if you enable them.


Commit Hash

5b8e6de

Expected Behavior

Builds cleanly (no warnings).

Actual Behavior

Building generates warnings, as follows:

  1. An uninitialized-member warning due to member variables cmd_ and vtable_ not having default initializers and not being explicitly initialized in the default constructor for class type_erasure::tables::vtable.
member 'cmd_' is missing from constructor initializer list [-Werror,-Wuninitialized-member]
member 'vtable_' is missing from constructor initializer list [-Werror,-Wuninitialized-member]

Easily fixed by changing the member declarations this:

    command_function_t cmd_{nullptr};
    typename invoke_table_t::type vtable_{nullptr};
  1. The use of the variable name allocator in various places triggers a shadow warning, due to the base class in libstdc++ also using it. (note: this is a gcc warning and was built with gcc, not clang)
declaration of 'allocator' shadows a member of ... [-Werror=shadow]
include/c++/7/bits/allocator.h:109:5: note: shadowed declaration is here
  1. The enum class opcode enumerations use doxygen-like comments that don't follow doxygen correctly, triggering a documentation warning.
not a Doxygen trailing comment [-Werror,-Wdocumentation]
     op_move,         //< Move the object and set the vtable
                      ^~~
                      ///<

Changing them to this fixes it:

enum class opcode
{
    op_move,         ///< Move the object and set the vtable
    op_copy,         ///< Copy the object and set the vtable
    op_destroy,      ///< Destroy the object and reset the vtable
    op_weak_destroy, ///< Destroy the object without resetting the vtable
    op_fetch_empty,  ///< Stores true or false into the to storage
                     ///< to indicate emptiness
};

Steps to Reproduce

Build using clang with -Weverything or the specific warnings described earlier, except for (2) which was found using gcc.

This was built simply as a copied header - i.e., not using the CMake settings in this project. (built for C++17)

Your Environment

  • OS: Linux
  • Compiler and version: clang version 5.0.0
  • Standard library (if non default): gcc's libstdc++ (from gcc version 7.3.1)

hadrielk avatar Sep 26 '19 18:09 hadrielk

Thanks for your report. The uninitialized-member warning is triggered because some members are initialized in the content of the constructor, mayne this can be improved. The other warnings will be fixed soon.

Naios avatar Sep 26 '19 18:09 Naios