https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113676

--- Comment #2 from Magnus Hokland Hegdahl <magnus.hegdahl at gmail dot com> ---
Hi, here's a version that doesn't need -std=c++20 or argv:

https://godbolt.org/z/Y9ooY998e

#include <vector>

constexpr auto bit_ceil(unsigned x) -> unsigned {
    if (x <= 1) return 1U;
    int w = 32 - __builtin_clz(x - 1);
    return 1U << w;
}

int main(int argc, char **) {
    auto rounded_n = bit_ceil(static_cast<unsigned>(argc + 1));
    auto a = std::vector<int>(2UL * rounded_n);

    for (std::size_t i = rounded_n; i-- > 1;) {
        if (!(0 < i && i < rounded_n)) __builtin_unreachable();
        a[i] = 0;
    }
}

Exact compile command used with g++-12 (GCC) 12.3.0 on arch linux, x86_64:
g++-12 -O1 -ftree-vrp main.cpp

Reply via email to