This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix LBOUND with assumed size array and non constant DIM
ClosedPublic

Authored by clementval on Jun 24 2022, 2:01 AM.

Details

Summary

LBOUND with a non constant DIM argument use the runtime to allow runtime
verification of DIM <= RANK. The interface uses a descriptor. This caused
undefined behavior because the runtime believed it was seeing an explicit
shape arrays with zero extent and returned 1 (the runtime descriptor
does not allow making a difference between an explicit shape and an
assumed size. Assumed size are not meant to be described by runtime
descriptors).

Fix the issue by setting the last extent of assumed size to 1 when
creating the descriptor to inquire about the LBOUND with the runtime.

This patch is part of the upstreaming effort from fir-dev branch.

Co-authored-by: Jean Perier <jperier@nvidia.com>

Diff Detail

Event Timeline

clementval created this revision.Jun 24 2022, 2:01 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 24 2022, 2:01 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Jun 24 2022, 2:01 AM
PeteSteinfeld accepted this revision.Jun 24 2022, 6:58 AM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Jun 24 2022, 6:58 AM