Strange C6385 warning in Vulkan initialization code

Viewed 220

I'm making a Vulkan initializer and I'm trying to print out properties of the physical devices Vulkan recognizes. I'm not encountering any errors or crashes, but I'm getting a scary "C6385 Reading invalid data from 'physicalDevices': the readable size is 'physicalDeviceCount*4' bytes, but '8' bytes may be read." warning. Since it's creating any real problems and I've read that there are sometimes false positives with this it doesn't bother me too much, but I think I'm engaging in some possibly problematic bp with this.

The code that runs in printStats() doesn't seem to be the Problem. I've tried to control for cases where a buffer overrun might occur (for example with if(physicalDeviceCount)), but it didn't seem to make the warning go away.

// VulkanTest.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include "vulkan\vulkan.h"

#define ASSERT_VULKAN(val)\
        if(val != VK_SUCCESS){\
            __debugbreak();\
        }


VkInstance instance;

void printStats(VkPhysicalDevice& device) {
    VkPhysicalDeviceProperties properties;
    vkGetPhysicalDeviceProperties(device, &properties);

    VkPhysicalDeviceFeatures features;
    vkGetPhysicalDeviceFeatures(device, &features);

    VkPhysicalDeviceMemoryProperties memProp;
    vkGetPhysicalDeviceMemoryProperties(device, &memProp);

    std::cout << properties.deviceName << std::endl;
    uint32_t apiVersion = properties.apiVersion;
    std::cout << VK_VERSION_MAJOR(apiVersion) << "." << VK_VERSION_MINOR(apiVersion) << "." << VK_VERSION_PATCH(apiVersion) << std::endl;
    std::cout << properties.driverVersion << std::endl;
    std::cout << properties.vendorID << std::endl;
    std::cout << properties.deviceID << std::endl;
    std::cout << properties.deviceType << std::endl;

    std::cout << features.geometryShader << std::endl;



}

int main()
{
    VkApplicationInfo appInfo;
    appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
    appInfo.pNext = NULL;
    appInfo.pApplicationName = "VulkanTest";
    appInfo.applicationVersion = VK_MAKE_VERSION(0, 0, 0);
    appInfo.pEngineName = "Vulkan";
    appInfo.engineVersion = VK_MAKE_VERSION(0, 0, 0);
    appInfo.apiVersion = VK_API_VERSION_1_1;

    VkInstanceCreateInfo instanceInfo;
    instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
    instanceInfo.pNext = NULL;
    instanceInfo.flags = 0;
    instanceInfo.pApplicationInfo = &appInfo;
    instanceInfo.enabledLayerCount = 0;
    instanceInfo.ppEnabledLayerNames = NULL;
    instanceInfo.enabledExtensionCount = 0;
    instanceInfo.ppEnabledExtensionNames = NULL;


    VkResult result = vkCreateInstance(&instanceInfo, NULL, &instance);
    ASSERT_VULKAN(result);

    uint32_t physicalDeviceCount = 0;
    result = vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, NULL);
    ASSERT_VULKAN(result);

    VkPhysicalDevice* physicalDevices = new VkPhysicalDevice[physicalDeviceCount];

    result = vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices);
    ASSERT_VULKAN(result);

        //warning here
    for (int i = 0; i < int(physicalDeviceCount); i++) {
        printStats(physicalDevices[i]);
    }

    return 0;
}

Warning C6385 Reading invalid data from 'physicalDevices': the readable size is 'physicalDeviceCount*4' bytes, but '8' bytes may be read. Line: 74

0 Answers
Related