-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.Category: This is a bug.
Description
Short summary: When an inline assembly constraint lacks its closing curly brace, the compiler segfaults when optimizing, and accepts the code when not optimizing.
Steps to reproduce:
- Write the following (invalid) code to some file (e.g.
main.rs
):
#![feature(asm)]
fn main() {
let rax: u64;
unsafe {asm!("", :"={rax"(rax))};
println!("Accumulator is: {}", rax);
}
(note the missing closing brace in the constraint)
- Compile it with optimization (i.e.
rustc -O main.rs
, on nightly because we use a feature flag) - Compile it without optimization (i.e.
rustc main.rs
)
Expected result
Error message that the constraint is not well-formed
Actual result
- With optimization: The compiler terminates with SIGSEGV (note: this happens with any optimization flag enabled)
- Without optimization: The code is silently accepted
Meta
rustc --version --verbose
:
rustc 1.30.0-nightly (0198a1ea4 2018-09-08)
binary: rustc
commit-hash: 0198a1ea45e29af00d92423aa6d2ac876410c3f9
commit-date: 2018-09-08
host: x86_64-unknown-linux-gnu
release: 1.30.0-nightly
LLVM version: 8.0
- Backtrace: not applicable (compiler does not panic)
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.Category: This is a bug.