Issue 153938
Summary [MC][ARM] `Clang` Crashes When Assembling Invalid ARM `ldrexd` Instructions with `--triple=armv7-none-eabi`
Labels clang
Assignees
Reporter venkyqz
    ## Description

When using the latest **trunk assertions build** of Clang/`llvm-mc` with the `--triple=armv7-none-eabi` option to assemble ARM assembly code containing invalid `ldrexd` instructions `ldrexd h0,r0,[r8]`, the assembler crashes with a **SIGSEGV** due to an assertion failure in `ARMAsmParser::parseInstruction` / `ARMOperand::getReg`.  

Expected behavior is to emit diagnostics (e.g., “invalid instruction”, “destination operands must be sequential”), not to crash.
---

## Interesting Facts

- **Clang 18.1.0**:  
  - Clang **18.1.0** with the same triple/inputs produces correct error messages and exits cleanly (**no crash**).  
  - This is the latest version that still works, indicating a bug introduced after 18.1.0.

- **ARM gcc 15.1**:  
  With `arm-linux-gnueabi-gcc -march=armv7-a`, GNU `as` correctly diagnoses the invalid instructions with errors such as:  
  - ARM register expected -- `ldrexd h0,r0,[r8]'
  It does **not crash**.
---

## Steps to reproduce

This issue was reproduced in Compiler Explorer using `x86-64 Clang (trunk with assertions)`,`x86-64 Clang 18.1.0`, and `arm gcc 15.1`
Comprehensive reproduce link: [https://godbolt.org/z/TW6WcqKWj](https://godbolt.org/z/TW6WcqKWj)

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to