-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
std::thread::panicking() doesn't simplify to false when compiled with panic=abort #151458
Copy link
Copy link
Closed
Closed
Copy link
Labels
-Zbuild-stdUnstable cargo option: -Zbuild-stdUnstable cargo option: -Zbuild-stdA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-panicArea: Panicking machineryArea: Panicking machineryC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
-Zbuild-stdUnstable cargo option: -Zbuild-stdUnstable cargo option: -Zbuild-stdA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-panicArea: Panicking machineryArea: Panicking machineryC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I tried compiling this code with
-C panic=abort:I expected to see this happen: this should simplify to
falsebecause the documentation ofpanicking()says "Determines whether the current thread is unwinding because of panic", but the current thread cannot be unwinding when we are inpanic=abortmode.Instead, this happened: a dozen instructions are generated, referring to
GLOBAL_PANIC_COUNT, etc. See https://rust.godbolt.org/z/93Yax7rT9.Can the implementation be changed to something like this? Due to constant folding, this could potentially automatically optimize away a lot of code referring to
std::thread::panicking()when compiled inpanic=abortmode.Meta
Rust version 1.92.0 on https://rust.godbolt.org/