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

            Bug ID: 118226
           Summary: packed index out of range error message could be
                    improved
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
template<auto... x>
constexpr int y = x...[x...[x...[0]]];

int main() {
        return y<3,3,2>;
}
```

Currently GCC produces:
```

<source>: In instantiation of 'constexpr const int y<3, 3, 2>':
<source>:5:9:   required from here
    5 |         return y<3,3,2>;
      |                ^~~~~~~~
<source>:2:15: error: pack index is out of range
    2 | constexpr int y = x...[x...[x...[0]]];
      |               ^
<source>:2:15: error: pack index is not an integral constant

```

It tells me the pack index is out of range but not the value of the index nor
the range or even points me to which expression is the problem.

While clang produces:
```
<source>:2:24: error: invalid index 3 for pack x of size 3
    2 | constexpr int y = x...[x...[x...[0]]];
      |                        ^
<source>:5:9: note: in instantiation of variable template specialization 'y<3,
3, 2>' requested here
    5 |         return y<3,3,2>;
      |                ^
```

Which tells me what the range and index being used though and even which index
is the issue.

Reply via email to