Skip to content
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

[IR]: Bug - dangling reference #105778

Closed
root-kidik opened this issue Aug 23, 2024 · 1 comment · Fixed by #127400
Closed

[IR]: Bug - dangling reference #105778

root-kidik opened this issue Aug 23, 2024 · 1 comment · Fixed by #127400

Comments

@root-kidik
Copy link

/llvm-project/llvm/include/llvm/IR/DiagnosticInfo.h:584:10: error: cannot bind non-const lvalue reference of type 'llvm::OptimizationRemarkMissed&' to an rvalue of type 'llvm::OptimizationRemarkMissed'     
@Chen-Carl
Copy link

I encountered the same error when compiling with the latest gcc-15.0.0.

image

An OptimizationRemarkMissed instance is constructed as a temporary object using the return value. This temporary object is an rvalue, and the code attempts to use it continuously, especially when using the stream operator <<.

You can modify the code like this:

ORE.emit([&]() {
  OptimizationRemarkMissed R(DEBUG_TYPE, "IncreaseCostInOtherContexts", Call);
  R << "Not inlining. Cost of inlining '" << NV("Callee", Callee)
     << "' increases the cost of inlining '" << NV("Caller", Caller)
     << "' in other contexts";
return R;
});

hahnjo added a commit to hahnjo/llvm-project that referenced this issue Feb 16, 2025
This fixes compilation issues with GCC and C++23:
```
error: cannot bind non-const lvalue reference of type
'llvm::OptimizationRemarkMissed&' to an rvalue of type
'llvm::OptimizationRemarkMissed'
```

Closes llvm#105778
@arsenm arsenm closed this as completed in 44ff94e Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants