Skip to content

Commit 8d0fb9f

Browse files
authored
[flang] Make the length size matched in comparison (NFC) (#73280)
The template function call `CheckDescriptorEqInt(length.get(), 16)` is deduced to have `INT_T` equal to `std::int32_t` instead of `std::int64_t`, but the length descriptor points to a 64-byte storage. The comparison does not work in a big endian.
1 parent a599a61 commit 8d0fb9f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

flang/unittests/Runtime/CommandTest.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class CommandFixture : public ::testing::Test {
171171
std::string spaces(value->ElementBytes(), ' ');
172172
CheckDescriptorEqStr(value.get(), spaces);
173173

174-
CheckDescriptorEqInt(length.get(), 0);
174+
CheckDescriptorEqInt<std::int64_t>(length.get(), 0);
175175

176176
if (errStr) {
177177
std::string paddedErrStr(GetPaddedStr(errStr, err->ElementBytes()));
@@ -193,7 +193,7 @@ class CommandFixture : public ::testing::Test {
193193
std::string spaces(value->ElementBytes(), ' ');
194194
CheckDescriptorEqStr(value.get(), spaces);
195195

196-
CheckDescriptorEqInt(length.get(), 0);
196+
CheckDescriptorEqInt<std::int64_t>(length.get(), 0);
197197

198198
if (errStr) {
199199
std::string paddedErrStr(GetPaddedStr(errStr, err->ElementBytes()));
@@ -294,7 +294,7 @@ TEST_F(SeveralArguments, ArgValueTooShort) {
294294
RTNAME(GetCommandArgument)(1, tooShort.get(), length.get(), errMsg.get()),
295295
-1);
296296

297-
CheckDescriptorEqInt(length.get(), 16);
297+
CheckDescriptorEqInt<std::int64_t>(length.get(), 16);
298298
std::string expectedErrMsg{
299299
GetPaddedStr("Value too short", errMsg->ElementBytes())};
300300
CheckDescriptorEqStr(errMsg.get(), expectedErrMsg);
@@ -320,7 +320,7 @@ TEST_F(SeveralArguments, CommandErrMsgTooShort) {
320320

321321
std::string spaces(value->ElementBytes(), ' ');
322322
CheckDescriptorEqStr(value.get(), spaces);
323-
CheckDescriptorEqInt(length.get(), 0);
323+
CheckDescriptorEqInt<std::int64_t>(length.get(), 0);
324324
CheckDescriptorEqStr(errMsg.get(), "Mis");
325325
}
326326

@@ -351,7 +351,7 @@ TEST_F(OnlyValidArguments, CommandValueTooShort) {
351351

352352
CheckDescriptorEqStr(
353353
tooShort.get(), "aProgram -f has/a/few/slashes has\\a\\few\\backslashe");
354-
CheckDescriptorEqInt(length.get(), 51);
354+
CheckDescriptorEqInt<std::int64_t>(length.get(), 51);
355355

356356
OwningPtr<Descriptor> errMsg{CreateEmptyCharDescriptor()};
357357
ASSERT_NE(errMsg, nullptr);
@@ -377,7 +377,7 @@ TEST_F(OnlyValidArguments, GetCommandCanTakeNull) {
377377
value->ElementBytes()));
378378

379379
EXPECT_EQ(0, RTNAME(GetCommand)(nullptr, length.get(), nullptr));
380-
CheckDescriptorEqInt(length.get(), 51);
380+
CheckDescriptorEqInt<std::int64_t>(length.get(), 51);
381381
}
382382

383383
TEST_F(OnlyValidArguments, GetCommandShortLength) {

0 commit comments

Comments
 (0)