GPUOpen-Archive / Anvil

Anvil is a cross-platform framework for Vulkan
MIT License
594 stars 62 forks source link

Error compiling with GCC 9 on Linux #155

Open dmarian opened 4 years ago

dmarian commented 4 years ago

When compiling with GCC 9 on Linux I get these errors: Libs/Anvil/src/misc/types_struct.cpp: In constructor ‘Anvil::FormatProperties::FormatProperties()’: Libs/Anvil/src/misc/types_struct.cpp:1168:26: error: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct Anvil::FormatProperties’ with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess] 1168 | sizeof(*this) ); | ^ In file included from Libs/Anvil/include/misc/types_classes.h:25, from Libs/Anvil/include/misc/types.h:286, from Libs/Anvil/include/misc/descriptor_set_create_info.h:26, from Libs/Anvil/src/misc/types_struct.cpp:22: Libs/Anvil/include/misc/types_struct.h:1272:20: note: ‘struct Anvil::FormatProperties’ declared here 1272 | typedef struct FormatProperties | ^~~~~~~~~~~~~~~~ Libs/Anvil/src/misc/types_struct.cpp: In constructor ‘Anvil::SparseImageAspectProperties::SparseImageAspectProperties()’: Libs/Anvil/src/misc/types_struct.cpp:3792:26: error: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct Anvil::SparseImageAspectProperties’ with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess] 3792 | sizeof(*this) ); | ^ In file included from Libs/Anvil/include/misc/types_classes.h:25, from Libs/Anvil/include/misc/types.h:286, from Libs/Anvil/include/misc/descriptor_set_create_info.h:26, from Libs/Anvil/src/misc/types_struct.cpp:22: Libs/Anvil/include/misc/types_struct.h:2854:20: note: ‘struct Anvil::SparseImageAspectProperties’ declared here 2854 | typedef struct SparseImageAspectProperties | ^~~~~~~~~~~~~~~~~~~~~~~~~~~

VaelynPhi commented 4 years ago

Can confirm still an issue; the offending code is the memset in these structs' empty initializers; I think in C++11 forward these can just be empty, as the struct is zero-initialized by default; or like I did just set each member to its empty initializer:

Anvil::SparseImageAspectProperties::SparseImageAspectProperties()
{
        aspect_mask = {};
        flags = {};
        granularity = {};
        mip_tail_first_lod = {};
        mip_tail_offset = {};
        mip_tail_size = {};
        mip_tail_stride = {};

    // memset(this,
    //        0,
    //        sizeof(*this) );
}

And

Anvil::FormatProperties::FormatProperties()
{
    buffer_capabilities = {};
    linear_tiling_capabilities = {};
    optimal_tiling_capabilities = {};
    // memset(this,
    //        0,
    //        sizeof(*this) );
}

@dmarian if you were still trying to build. If any maintainers would like a pull request, I don't mind putting one together, but I imagine ya'll probably have a better notion of what you'd prefer to do here than I.