Skip to content

<ranges>: views::cartesian_product and views::filter emit spurious warning C4324 'structure was padded due to alignment specifier' #4425

@StephanTLavavej

Description

@StephanTLavavej
D:\GitHub\STL\out\x64>type meow.cpp
#include <print>
#include <ranges>
#include <vector>
using namespace std;

int main() {
    const vector<int> vec{11, 22, 33};
    auto always_true = [](const auto&) { return true; };

    for (const auto& [e0, e1] : views::cartesian_product(vec, vec) | views::filter(always_true)) {
        println("{} {}", e0, e1);
    }
}
D:\GitHub\STL\out\x64>cl /EHsc /nologo /W4 /std:c++latest /MTd /Od meow.cpp
meow.cpp
D:\GitHub\STL\out\x64\out\inc\ranges(2403): warning C4324: 'std::ranges::filter_view<std::ranges::cartesian_product_view<std::ranges::ref_view<const std::vector<int,std::allocator<int>>>,std::ranges::ref_view<const std::vector<int,std::allocator<int>>>>,main::<lambda_1>>': structure was padded due to alignment specifier
D:\GitHub\STL\out\x64\out\inc\ranges(2403): note: the template instantiation context (the oldest one first) is
D:\GitHub\STL\out\x64\out\inc\ranges(198): note: while compiling class template member function 'decltype(auto) std::ranges::_Range_closure<std::ranges::views::_Filter_fn,main::<lambda_1>>::operator ()(_Ty &&) noexcept(<expr>) &'
D:\GitHub\STL\out\x64\out\inc\ranges(930): note: while evaluating concept 'invocable<std::ranges::views::_Filter_fn,std::ranges::cartesian_product_view<std::ranges::ref_view<std::vector<int,std::allocator<int> > const >,std::ranges::ref_view<std::vector<int,std::allocator<int> > const > >,`main'::`2'::<lambda_1> &>'
D:\GitHub\STL\out\x64\out\inc\ranges(2418): note: see reference to class template instantiation 'std::ranges::filter_view<std::ranges::cartesian_product_view<std::ranges::ref_view<const std::vector<int,std::allocator<int>>>,std::ranges::ref_view<const std::vector<int,std::allocator<int>>>>,main::<lambda_1>>' being compiled

D:\GitHub\STL\out\x64>meow
11 11
11 22
11 33
22 11
22 22
22 33
33 11
33 22
33 33

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!rangesC++20/23 ranges

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions