[flang-commits] [PATCH] D149062: [flang][runtime] Fix padding in CHARACTER(4) assignments.
Jean Perier via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Apr 24 06:40:38 PDT 2023
jeanPerier created this revision.
jeanPerier added reviewers: vzakhari, klausler.
jeanPerier added a project: Flang.
Herald added subscribers: sunshaoce, jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.
One piece of pointer arithmetic was adding the number of bytes instead
of the number of characters. This caused failures in CHARACTER(KIND>1)
that required padding.
This was caught using HLFIR that currently uses the runtime for array
assignment where the current lowering does everything inline.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D149062
Files:
flang/runtime/assign.cpp
Index: flang/runtime/assign.cpp
===================================================================
--- flang/runtime/assign.cpp
+++ flang/runtime/assign.cpp
@@ -223,12 +223,13 @@
SubscriptValue toAt[], SubscriptValue fromAt[], std::size_t elements,
std::size_t toElementBytes, std::size_t fromElementBytes) {
std::size_t padding{(toElementBytes - fromElementBytes) / sizeof(CHAR)};
+ std::size_t copiedCharacters{fromElementBytes / sizeof(CHAR)};
for (; elements-- > 0;
to.IncrementSubscripts(toAt), from.IncrementSubscripts(fromAt)) {
CHAR *p{to.Element<CHAR>(toAt)};
std::memmove(
p, from.Element<std::add_const_t<CHAR>>(fromAt), fromElementBytes);
- p += fromElementBytes;
+ p += copiedCharacters;
for (auto n{padding}; n-- > 0;) {
*p++ = CHAR{' '};
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149062.516386.patch
Type: text/x-patch
Size: 823 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230424/a6be2281/attachment-0001.bin>
More information about the flang-commits
mailing list