Skip to content

Rejects-valid with static_assert referring to templated array variable with incomplete bound #133963

Open
@efriedma-quic

Description

@efriedma-quic
template<int x> int a[] = {1,2,3};
static_assert(a<1> + 1 - a<1> == 1);
<source>:2:15: error: static assertion expression is not an integral constant expression
    2 | static_assert(a<1> + 1 - a<1> == 1);
      |               ^~~~~~~~~~~~~~~~~~~~
<source>:2:20: note: indexing of array without known bound is not allowed in a constant expression
    2 | static_assert(a<1> + 1 - a<1> == 1);
      |                    ^
1 error generated.

This seems wrong; I think referring to the array like this should force the computation of the correct type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"rejects-valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions