Skip to content

[flang][bbc] Fix dangling reference to envDefaults #82800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

kparzysz
Copy link
Contributor

The lowering bridge stores the evvironment defaults (passed to the constructor) as a reference. In the call to the constructor in bbc, the defaults were passed as {}, which creates a temporary whose lifetime ends immediately after the call.

The flang driver passes a member of the compilation instance to the constructor, which presumably remains alive long enough, so storing the reference in the bridge is justified. To avoid the dangling reference, create an actual object envDefaults in bbc.

The lowering bridge stores the evvironment defaults (passed to the
constructor) as a reference. In the call to the constructor in bbc,
the defaults were passed as `{}`, which creates a temporary whose
lifetime ends immediately after the call.

The flang driver passes a member of the compilation instance to the
constructor, which presumably remains alive long enough, so storing
the reference in the bridge is justified. To avoid the dangling
reference, create an actual object `envDefaults` in bbc.
Copy link
Contributor

@agozillon agozillon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Contributor

@clementval clementval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine.

@kparzysz
Copy link
Contributor Author

Linux tests passed, the only test that failed on Windows also failed in other builds: Flang :: Fir/memory-allocation-opt.fir, for example: https://buildkite.com/llvm-project/github-pull-requests/builds/41408.

@kparzysz kparzysz merged commit a24421f into llvm:main Feb 23, 2024
@kparzysz kparzysz deleted the dangling-envdefaults branch February 23, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants