microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

IntelliSense hover and inlay hints incorrect reports type "unnamed" instead of "const float&" #12961

Open sean-mcmanus opened 4 days ago

sean-mcmanus commented 4 days ago

Repro code is

#include <array>

template <std::size_t N>
constexpr auto transform(const std::array<float, N>& arr)
{
    std::array<int, N> values;
    for (std::size_t i{0}; const auto& k : arr)
    {
        static_assert(std::is_same_v<decltype(k), const float&>);
        constexpr auto j = 0;
        values[j] = k;  // change this j to i and you get a different error as well
        ++i;
    }
    return values;
}

int main()
{
    constexpr auto values = transform(std::array{0.f});
}

using C++ 20. Based on the repro in https://github.com/microsoft/vscode-cpptools/issues/8673 .

VS screenshot: Image

sean-mcmanus commented 4 days ago

I've filed a VS bug at https://developercommunity.visualstudio.com/t/C-IntelliSense-hover-and-inlay-hints-i/10789337 .