Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some compiler warnings are generated #30

Open
hadrielk opened this issue Sep 26, 2019 · 1 comment
Open

Some compiler warnings are generated #30

hadrielk opened this issue Sep 26, 2019 · 1 comment
Labels

Comments

@hadrielk
Copy link

@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)
@Naios
Copy link
Owner

Naios commented Sep 26, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants