forked from OSchip/llvm-project
[flang][runtime] Fix return value for MINVAL/MAXVAL for CHARACTER(kind > 1)
CharacterExtremumAccumulator::GetResult() needs to use byte counts, not wide character counts, when calling memcpy() & memset(). Differential Revision: https://reviews.llvm.org/D132156
This commit is contained in:
parent
92afe80213
commit
cd117fa04b
|
@ -419,11 +419,16 @@ public:
|
|||
void Reinitialize() { extremum_ = nullptr; }
|
||||
template <typename A> void GetResult(A *p, int /*zeroBasedDim*/ = -1) const {
|
||||
static_assert(std::is_same_v<A, Type>);
|
||||
std::size_t byteSize{array_.ElementBytes()};
|
||||
if (extremum_) {
|
||||
std::memcpy(p, extremum_, charLen_);
|
||||
std::memcpy(p, extremum_, byteSize);
|
||||
} else {
|
||||
// empty array: result is all zero-valued characters
|
||||
std::memset(p, 0, charLen_);
|
||||
// empty array
|
||||
if constexpr (KIND == 1) { // ASCII
|
||||
*p = IS_MAXVAL ? 0 : 127; // 127 required by standard
|
||||
} else {
|
||||
std::memset(p, IS_MAXVAL ? 0 : 255, byteSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool Accumulate(const Type *x) {
|
||||
|
|
Loading…
Reference in New Issue