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
Binding to TriaAccessor reference returned by dereferencing a TriaIterator temporary leads to use after scope #15440
Comments
Stacktrace: (
Stacktrace: (
|
This looks odd: I don't remember why I derefernced the iterator (and should not assigned to a reference); but one does not need the accessor but can work directly with the iterator... |
@peterrum Would you mind to open a PR that replaces the expression by the iterator using |
I agree that it looks funny, but I don't think it's wrong -- binding a temporary to a reference is allowed. But it's worth fixing anyway. Give it a try! |
@tamiko Do any of these tests fail in debug mode? |
@bangerth No, they do not fail in debug mode. |
I think the mistake might be that a non-const lvalue cannot bind to a temporary. |
Oh, the |
But this should be a compiler error... I am confused. |
But here we go:
|
|
Ah, this is a really subtle point:
Minimal reproducer:
Keeping the iterator temporary alive "fixes" the problem:
|
Ah, you're right. |
I think the only proper fix is to return a value and not a reference. Currently the syntax I am baffled that we never spotted this. (Actually thinking about this a bit more: the unavailability of |
That's a problem for after the release :-) |
I see a segmentation fault in release mode in the test
matrix_free/pbc_orientation_02.release
:I am working on producing a better stack trace. Related failing tests (failing in optimized release mode)
In reference to #15383
The text was updated successfully, but these errors were encountered: