According to section 9.4.1, paragraph 3,
If the starting point is greater than the ending point, the substring has
length zero
But the compilers code for substring processing was failing a call to `CHECK()`
in this case. I fixed this by just setting the number of items in the
resulting string to 0 for this situation.
Differential Revision: https://reviews.llvm.org/D87799
*ubi = *length;
}
if (lbi && literal) {
- CHECK(*ubi >= *lbi);
auto newStaticData{StaticDataObject::Create()};
- auto items{*ubi - *lbi + 1};
+ auto items{0}; // If the lower bound is greater, the length is 0
+ if (*ubi >= *lbi) {
+ items = *ubi - *lbi + 1;
+ }
auto width{(*literal)->itemBytes()};
auto bytes{items * width};
auto startByte{(*lbi - 1) * width};
end type
character :: a(10)
character :: b(5)
+ character :: c(0)
integer :: n
n = 3
b = a(n:7)
a(n+3:) = b
a(:n+2) = b
n = iachar(1_'ABCDEFGHIJ'(1:1))
+ c = 'ABCDEFGHIJ'(1:0)
end
! Test pointer assignment with bounds