<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/104431>104431</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang 18.1.8 crash when compiling with -m16 on Windows MinGW
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rfl890
      </td>
    </tr>
</table>

<pre>
    Crash backtrace:
```
Stack dump:
0.      Program arguments: C:/Users/RFL890/bin/llvm-mingw-20240619-ucrt-x86_64/bin/clang-18.exe -cc1 -triple i386-w64-windows-code16 -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.c -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu pentium4 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=C:/Users/RFL890/AppData/Local/Cmder -fcoverage-compilation-dir=C:/Users/RFL890/AppData/Local/Cmder -resource-dir C:/Users/RFL890/bin/llvm-mingw-20240619-ucrt-x86_64/lib/clang/18 -ferror-limit 19 -fmessage-length=168 -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -o C:/Users/RFL890/AppData/Local/Temp/main-932bf5.o -x c main.c
1.      <eof> parser at end of file
2.      Code generation
Exception Code: 0x80000003
 #0 0x000007fee446df11 llvm::MCWinCOFFStreamer::emitIdent(llvm::StringRef) (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\libLLVM-18.dll+0x1abdf11)
 #1 0x000007fee3562ab4 llvm::AsmPrinter::emitModuleIdents(llvm::Module&) (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\libLLVM-18.dll+0xbb2ab4)
 #2 0x000007fee3561e78 llvm::AsmPrinter::doFinalization(llvm::Module&) (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\libLLVM-18.dll+0xbb1e78)
 #3 0x000007fee2c903a1 llvm::FPPassManager::doFinalization(llvm::Module&) (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\libLLVM-18.dll+0x2e03a1)
 #4 0x000007fee2c8a611 llvm::legacy::PassManagerImpl::run(llvm::Module&) (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\libLLVM-18.dll+0x2da611)
 #5 0x000007fee7ecd9be clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\libclang-cpp.dll+0x132d9be)
 #6 0x000007fee82a3b3e clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\libclang-cpp.dll+0x1703b3e)
 #7 0x000007fee6d5f734 clang::ParseAST(clang::Sema&, bool, bool) (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\libclang-cpp.dll+0x1bf734)
 #8 0x000007fee8d7e704 clang::FrontendAction::Execute() (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\libclang-cpp.dll+0x21de704)
 #9 0x000007fee8cfbe94 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\libclang-cpp.dll+0x215be94)
#10 0x000007fee8dfcc9c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\libclang-cpp.dll+0x225cc9c)
#11 0x000000013f7b78e9 (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\clang-18.exe+0x78e9)
#12 0x000000013f7b5025 (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\clang-18.exe+0x5025)
#13 0x000000013f7b3f60 (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\clang-18.exe+0x3f60)
#14 0x000000013f7c259d (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\clang-18.exe+0x1259d)
#15 0x000000013f7b1311 (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\clang-18.exe+0x1311)
#16 0x000000013f7b1366 (C:\Users\RFL890\bin\llvm-mingw-20240619-ucrt-x86_64\bin\clang-18.exe+0x1366)
#17 0x00000000777a3d4d (C:\Windows\system32\kernel32.dll+0x13d4d)
#18 0x000000007790273d (C:\Windows\SYSTEM32\ntdll.dll+0x5273d)
clang-18: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 18.1.8 (https://github.com/llvm/llvm-project.git 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
Target: i386-w64-windows-code16
Thread model: posix
InstalledDir: C:/Users/RFL890/bin/llvm-mingw-20240619-ucrt-x86_64/bin
```

[Preprocessed source and associated run script](https://github.com/user-attachments/files/16624568/attachments.zip)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWF9v2zgS_zTMC0FDov4_-CG1470CDRo02SvuKaDIocwtRepIKnH30x8oObGVpi0O1-xeUNQ2OZr5_eafyGHeq84ArFHxDhXbCzaGvXVrJ3XdJBetFV_XG8f8HreMfwmOcUDZJUq2KLlEZXL8N_28DYx_wWLsh2eJZIWnvxtnO8d6zFw39mCCR9kl3kQxuvvdg_OI7j7tPtRNguiuVQbRndYPPemV6R4JTWielGlDRu4COdTlfZk_y3HN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