https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95241
Bug ID: 95241
Summary: internal compiler error: tree check: expected
integer_cst, have range_expr in to_wide, at
tree.h:5900
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tab.debugteam at gmail dot com
Target Milestone: ---
Following c++ code:
```
struct Fragment
{
int offset;
int length;
constexpr Fragment(
int _offset,
int _length)
: offset(_offset), length(_length)
{
}
constexpr Fragment() :
Fragment(0, 1) { }
};
struct Field {
Fragment fragments[3];
constexpr
Field(int offset, int length)
: fragments{Fragment(offset, length)}
{
}
};
int main()
{
auto field = Field(0, 1);
return 0;
}
```
fails to compile with gcc 10.1 (https://godbolt.org/z/tyPB6V) and later with
error message:
```
<source>: In function 'int main()':
<source>:28:28: in 'constexpr' expansion of 'Field(0, 1)'
<source>:28:28: internal compiler error: tree check: expected integer_cst, have
range_expr in to_wide, at tree.h:5900
28 | auto field = Field(0, 1);
| ^
```
First spotted on gcc 10.1: https://godbolt.org/z/tyPB6V, but it's also
reproducible on latest gcc available on compiler explorer (version 11.0.0
20200511): https://godbolt.org/z/qWivJC.
I'm unable to reproduce it on gcc 9.3: https://godbolt.org/z/C2QqxA.