function2
function2 copied to clipboard
Some compiler warnings are generated
@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:
- An
uninitialized-memberwarning due to member variablescmd_andvtable_not having default initializers and not being explicitly initialized in the default constructor for classtype_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};
- The use of the variable name
allocatorin various places triggers a shadow warning, due to the base class in libstdc++ also using it. (note: this is agccwarning and was built withgcc, notclang)
declaration of 'allocator' shadows a member of ... [-Werror=shadow]
include/c++/7/bits/allocator.h:109:5: note: shadowed declaration is here
- The enum class
opcodeenumerations use doxygen-like comments that don't follow doxygen correctly, triggering adocumentationwarning.
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)
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.