[flang-commits] [flang] [flang] fix hlfir stack merging issue on AIX (PR #78435)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Wed Jan 17 07:40:45 PST 2024


https://github.com/tblah approved this pull request.

LGTM. Nice find.

Please could you change the commit title/message. From what I can tell, stack merging or anything AIX specific are not the issues here (the problem just happens to only currently show up under these conditions). This fixes undefined behavior on all platforms.

As @stefanp-ibm said, `mlir::ValueRange` does not own the data it allows iteration over. Therefore, once the initializer_list goes out of scope (after the constructor returns), any access to the pointed-to memory (via the `ValueRange`) is unsafe.

The fix is correct because it extends the lifetime of the `initializer_list` to last as long as the `ValueRange`.

https://github.com/llvm/llvm-project/pull/78435


More information about the flang-commits mailing list