[flang-commits] [PATCH] D109813: [flang] GET_COMMAND_ARGUMENT(VALUE) runtime implementation

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Sep 16 08:42:41 PDT 2021


klausler added inline comments.


================
Comment at: flang/runtime/command.cpp:15
 namespace Fortran::runtime {
 using CountType = CppTypeFor<TypeCategory::Integer, 4>;
 using LengthType = CppTypeFor<TypeCategory::Integer, 8>;
----------------
If these types are used in the specifications of implementations of APIs then they should not be introduced here.  Implementations of functions should match their prototypes in headers, apart from maybe adding names for arguments and removing any default values.


================
Comment at: flang/runtime/command.cpp:72
+    }
+    if (argLen >= static_cast<LengthType>(value->ElementBytes())) {
+      return -1;
----------------
rovka wrote:
> It's not very clear to me from the standard what's supposed to happen to 'value' if it's too short. I guess it could be helpful to write as much of the argument as we can fit into it, but then we'd also have to decide whether we should put a \0 at the end or not (*), and overall I don't know if it's worth the trouble. Thoughts?
> 
> (*) IIUC gfortran doesn't force a \0, which makes the code easier but the testing harder, because I think it's UB to call EXPECT_STREQ on a char string that's not null-terminated.
Truncate if short, pad if long, and never append a NUL byte.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109813/new/

https://reviews.llvm.org/D109813



More information about the flang-commits mailing list