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
Avoid const return type in functions #15671
Conversation
template <typename type> | ||
const type | ||
type | ||
entry(const std::string &name) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could type
be a reference/pointer? And if so, would that make the pointer const, or the pointed to object const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The const
doesn't matter in that case either, see https://godbolt.org/z/8jesMca3a. Returning a constant pointer is the same as returning a non-constant pointer and a pointer to a constant type is still returned as such.
Several of the testers fail, at least one of them with this error message:
|
599879e
to
0b5a0ff
Compare
Still fails:
|
That is a pretty fascinating failure, by the way. It shows that the |
In short, this does not compile:
The error in the test probably points to a case where we shouldn't store a reference to begin with. |
Yes, also see https://godbolt.org/z/r5nhc6Yde. |
I wonder whether we want to reconsider this. It breaks ASPECT in ~4 places: geodynamics/aspect#5208 |
const
doesn't do anything when we are returning values.