YaaZ / VulkanMemoryAllocator-Hpp

C++ bindings for VulkanMemoryAllocator
Creative Commons Zero v1.0 Universal
57 stars 31 forks source link

Errors regarding spaceship operator and user-declared copy assignment operator #3

Closed saschasc closed 2 years ago

saschasc commented 2 years ago

@YaaZ Great that you continue this project. When compiling with clang 13.0.1 I get several warnings regarding the three-way comparison operator and user-declared copy assignment operator.

Tested with Vulkan SDK 1.3.211.0.

9 errors generated.

...

In file included from /home/username/vma-hpp-test/inc/Vulkan.h:67:
In file included from /home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc.hpp:15:
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:36:10: error: explicitly defaulted three-way comparison operator is implicitly deleted [-Werror,-Wdefaulted-function-deleted]
    auto operator<=>(DeviceMemoryCallbacks const &) const = default;
         ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:65:41: note: defaulted 'operator<=>' is implicitly deleted because there is no viable three-way comparison function for member 'pfnAllocate'
    PFN_vmaAllocateDeviceMemoryFunction pfnAllocate = {};
                                        ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:168:10: error: explicitly defaulted three-way comparison operator is implicitly deleted [-Werror,-Wdefaulted-function-deleted]
    auto operator<=>(VulkanFunctions const &) const = default;
         ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:351:31: note: defaulted 'operator<=>' is implicitly deleted because there is no viable three-way comparison function for member 'vkGetInstanceProcAddr'
    PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = {};
                              ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:560:20: error: definition of implicit copy constructor for 'AllocatorInfo' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
    AllocatorInfo& operator=(AllocatorInfo const &) VULKAN_HPP_NOEXCEPT = default;
                   ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_funcs.hpp:48:12: note: in implicit copy constructor for 'vma::AllocatorInfo' first required here
    return allocatorInfo;
           ^
In file included from /home/username/vma-hpp-test/inc/Vulkan.h:67:
In file included from /home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc.hpp:15:
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:806:22: error: definition of implicit copy constructor for 'TotalStatistics' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
    TotalStatistics& operator=(TotalStatistics const &) VULKAN_HPP_NOEXCEPT = default;
                     ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_funcs.hpp:103:12: note: in implicit copy constructor for 'vma::TotalStatistics' first required here
    return stats;
           ^
In file included from /home/username/vma-hpp-test/inc/Vulkan.h:67:
In file included from /home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc.hpp:15:
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:715:25: error: definition of implicit copy constructor for 'DetailedStatistics' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
    DetailedStatistics& operator=(DetailedStatistics const &) VULKAN_HPP_NOEXCEPT = default;
                        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/array:95:12: note: in implicit copy constructor for 'vma::DetailedStatistics' first required here
    struct array
           ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:791:10: note: in implicit copy constructor for 'std::array<vma::DetailedStatistics, 32>' first required here
  struct TotalStatistics {
         ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_funcs.hpp:103:12: note: in implicit copy constructor for 'vma::TotalStatistics' first required here
    return stats;
           ^
In file included from /home/username/vma-hpp-test/inc/Vulkan.h:67:
In file included from /home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc.hpp:15:
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:632:17: error: definition of implicit copy constructor for 'Statistics' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
    Statistics& operator=(Statistics const &) VULKAN_HPP_NOEXCEPT = default;
                ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:694:10: note: in implicit copy constructor for 'vma::Statistics' first required here
  struct DetailedStatistics {
         ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/array:95:12: note: in implicit copy constructor for 'vma::DetailedStatistics' first required here
    struct array
           ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:791:10: note: in implicit copy constructor for 'std::array<vma::DetailedStatistics, 32>' first required here
  struct TotalStatistics {
         ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_funcs.hpp:103:12: note: in implicit copy constructor for 'vma::TotalStatistics' first required here
    return stats;
           ^
In file included from /home/username/vma-hpp-test/inc/Vulkan.h:67:
In file included from /home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc.hpp:15:
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:1184:21: error: definition of implicit copy constructor for 'AllocationInfo' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
    AllocationInfo& operator=(AllocationInfo const &) VULKAN_HPP_NOEXCEPT = default;
                    ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_funcs.hpp:378:12: note: in implicit copy constructor for 'vma::AllocationInfo' first required here
    return allocationInfo;
           ^
In file included from /home/username/vma-hpp-test/inc/Vulkan.h:67:
In file included from /home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc.hpp:15:
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:1720:28: error: definition of implicit copy constructor for 'VirtualAllocationInfo' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
    VirtualAllocationInfo& operator=(VirtualAllocationInfo const &) VULKAN_HPP_NOEXCEPT = default;
                           ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_funcs.hpp:821:12: note: in implicit copy constructor for 'vma::VirtualAllocationInfo' first required here
    return virtualAllocInfo;
           ^
In file included from /home/username/vma-hpp-test/inc/Vulkan.h:67:
In file included from /home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc.hpp:15:
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_structs.hpp:1429:34: error: definition of implicit copy constructor for 'DefragmentationPassMoveInfo' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
    DefragmentationPassMoveInfo& operator=(DefragmentationPassMoveInfo const &) VULKAN_HPP_NOEXCEPT = default;
                                 ^
/usr/include/vulkan/vulkan.hpp:6079:12: note: in implicit copy constructor for 'vma::DefragmentationPassMoveInfo' first required here
    return std::move( data );
           ^
/home/username/vma-hpp-test/external/vma-hpp/vk_mem_alloc_funcs.hpp:559:12: note: in instantiation of function template specialization 'vk::createResultValueType<vma::DefragmentationPassMoveInfo>' requested here
    return createResultValueType(result, passInfo);
           ^
YaaZ commented 2 years ago

Hey @saschasc! I'm pretty sure you should be getting such warnings not only from VMA-Hpp, but from Vulkan-Hpp too, aren't you? These warnings make sense indeed, as there's no point in comparison of pointers&structs etc other than for equality, so I guess it would be okay to replace operator<=> = default with operator== = default... Buuuut I'm trying to stick close to the Vulkan-Hpp which has the same explicitly defaulted <=> operator for structs, that's why I'm asking whether you're getting the same warnings there. Then we can probably try PRing Vulkan-Hpp and update VMA-Hpp too.

YaaZ commented 2 years ago

Waiting for an answer: https://github.com/KhronosGroup/Vulkan-Hpp/issues/1315 In the meantime you can try the dev branch

saschasc commented 2 years ago

Currently, when upgrading to Vulkan SDK 1.3.211.0 I only have the warnings from VMA-Hpp. But I would have to look again into it. I was able to compile the whole project by fixing it only in VMA-Hpp.

I understand that you want to stick close to the Vulkan-Hpp project. This makes absolute sense for me, too.

Let's see what answer we will get :-)

Thanks!

YaaZ commented 2 years ago

Interestingly, I tested it with the same Clang and Vulkan-Hpp version and I got the same warnings from Vulkan-Hpp too.

saschasc commented 2 years ago

I have only recently changed to C++ 20 and therefore still had a define VULKAN_HPP_NO_CONSTRUCTORS activated. Then it did not compile. By removing this define it works with your changes from the dev branch.