-
-
Notifications
You must be signed in to change notification settings - Fork 15k
copy bindings in pattern guards are broken #3291
Copy link
Copy link
Closed
Labels
A-codegenArea: Code generationArea: Code generationI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Milestone
Description
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Type
Fields
Give feedbackNo fields configured for issues without a type.
This test segfaults:
the reason is that copy bindings (currently, anyhow) create a temporary that is only used in the guard, copy into it, and then free it on exit from the match. But this temporary is never initialized. If you wind up in an arm that doesn't use the temporary, then, you try to free uninitialized data. Bad.
It would be better for copy bindings to perform the copy, test the guard, then free the data if the guard is false---but reuse the data if the guard is true. I'm going to see how much surgery that would be.
Or maybe copy bindings and guards should just be incompatible?