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

--- Comment #9 from Jonathan Strobl <Jonathan.Strobl at gmx dot de> ---
Thanks a lot for fixing this so quickly!

Here's my two cents about whether to special-case attribute aligned or whether
to make a general solution: aligned isn't the only attribute that's affected.
It'd also make sense for things like vector_size to evaluate their arguments
with manifestly_const_eval; adding another column in the attribute table
therefore seems like a logical thing to do to me.

However, special-casing aligned for now is of course also a perfectly valid fix
until there's a more general solution.

Here's a small, somewhat realistic test case for vector_size that currently
fails because of the same problem:

constexpr unsigned bit_ceil(unsigned val) {
    bool a = __builtin_is_constant_evaluated();
    unsigned result = 1;
    while (result < val) result <<= 2;
    return result;
}

template<typename T, unsigned num>
struct VecImpl {
    typedef __attribute__((vector_size(bit_ceil(sizeof(T) * num)))) T type;
};

using Vec3f = VecImpl<float, 3>::type;

Reply via email to