Skip to content

[Clang] Matrix types are currently not supported in constant evaluation #120167

@Sirraide

Description

@Sirraide

We support vector types, so supporting matrices as well would make sense, even though it sounds like it’d be quite a bit of work as it would probably involve adding a new APValue kind.

As an example, this (https://godbolt.org/z/WE84hhYvP):

template <typename T>
constexpr bool f() {
    T t = T();
    return true;
}

using M = int [[clang::matrix_type(4, 4)]];

static_assert(f<M>());

doesn’t work currently:

<source>:9:15: error: static assertion expression is not an integral constant expression
    9 | static_assert(f<M>());
      |               ^~~~~~
<source>:3:11: note: non-literal type 'int __attribute__((matrix_type(4, 4)))' cannot be used in a constant expression
    3 |     T t = T();
      |           ^
<source>:9:15: note: in call to 'f<int __attribute__((matrix_type(4, 4)))>()'
    9 | static_assert(f<M>());
      |               ^~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions