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

    <tr>
        <th>Summary</th>
        <td>
            Clang crashes or hangs with unsigned long long int
        </td>
    </tr>

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

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

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

<pre>
    Clang trunk crashes on this code:
To reproduce: https://godbolt.org/z/KdKh74q3W
```c
const union  { 
    struct  { 
        char x  [0x10000000ULL];  
        char y  [4];   
    }; 
}     
u = { { "0", "0"}};   
int main  ( )   { 
    return 0;    
}
```

```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.      <eof> parser at end of file
2.      Code generation
 #0 0x000000000396eb08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x396eb08)
 #1 0x000000000396c6cc SignalHandler(int) Signals.cpp:0:0
 #2 0x0000720dea442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000720dea514887 __write (/lib/x86_64-linux-gnu/libc.so.6+0x114887)
 #4 0x0000000003945cea llvm::raw_fd_ostream::write_impl(char const*, unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3945cea)
 #5 0x0000000003946ba5 llvm::raw_ostream::write(char const*, unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3946ba5)
 #6 0x00000000038c945d llvm::formatted_raw_ostream::write_impl(char const*, unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x38c945d)
 #7 0x0000000003946ab2 llvm::raw_ostream::write(char const*, unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3946ab2)
 #8 0x0000000003675b74 llvm::MCSectionELF::printSwitchToSection(llvm::MCAsmInfo const&, llvm::Triple const&, llvm::raw_ostream&, unsigned int) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3675b74)
 #9 0x00000000036d91dd (anonymous namespace)::MCAsmStreamer::changeSection(llvm::MCSection*, unsigned int) MCAsmStreamer.cpp:0:0
#10 0x000000000367956b llvm::MCStreamer::switchSection(llvm::MCSection*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x367956b)
#11 0x000000000482b99b llvm::AsmPrinter::doFinalization(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x482b99b)
#12 0x00000000032da93d llvm::FPPassManager::doFinalization(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x32da93d)
#13 0x00000000032e6070 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x32e6070)
#14 0x0000000003c08fa5 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::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3c08fa5)
#15 0x00000000042b4a14 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x42b4a14)
#16 0x00000000062afb6c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x62afb6c)
#17 0x00000000042b5135 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x42b5135)
#18 0x000000000457de71 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x457de71)
#19 0x00000000044fdd3b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x44fdd3b)
#20 0x0000000004662293 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4662293)
#21 0x0000000000cebe0c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xcebe0c)
#22 0x0000000000ce486d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#23 0x00000000042fcf59 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#24 0x00000000038bdc23 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x38bdc23)
#25 0x00000000042fd179 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#26 0x00000000042c4b1d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x42c4b1d)
#27 0x00000000042c5b1d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x42c5b1d)
#28 0x00000000042cf0cc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x42cf0cc)
#29 0x0000000000ce8b61 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xce8b61)
#30 0x0000000000bb9fc4 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xbb9fc4)
#31 0x0000720dea429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#32 0x0000720dea429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#33 0x0000000000ce430e _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xce430e)
fatal error: error in backend: IO failure on output stream: File too large
Compiler returned: 1
```

Increasing the ULL causes the clang to hang
```c
const union  { 
    struct  { 
        char x  [0x100000000ULL];  
 char y  [4];   
    };   
}     
u = { { "0", "0"}};   
int main  ( )   { 
    return 0;    
}
```
```
Program terminated with signal: SIGKILL
Compiler returned: 137
```

Verified both works fine with gcc.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkmt1u27gSgJ9GuSFsSNSP5YtcOE68mzZFgzrdA-yNQZGUzBOJ1JJU4uzTH5CUbVFx0m6TFgucoGls_n6cGc6MPEZKsYpTeh6kF0F6eYY6vRXy_E-mBa_-3IruSjJ8VgjydL6sEa-Alh2_B1gitaUKCA70limABaFBvAjCyyBc3AkgaSsF6bBpBFutW2V64SqAq0qQQtR6KmQVwNXfAVx9JB-3s-Sv-D9uepCF7h9277HgSoOOM8EBCGYXwDUDAIDSssN63Gp-8BZJsAMgSC_CXRS6n683N0F6GcQX4NToJzs62Y8YDAlmtqnHm13aOe5dB4L40u1vfiEMAwgDuDy8nF32s_czGNegQcycBeYggHMw5pdUd5KD0M06bjsST__2VOPtzdVifQVUVzRMAwSKrjIqEVIDLcb6YHrbFVMsmgCu6vph_2fSSvFfinUAV0ypjqoArgDiBDCO645QoLfU2QEoEL7XEmFqDt5a3WOqFCVAiU66ZjMTKSUwQ5oSIDsOFJas1VOHvNYI3wPSNe3BjsJpEM5vpagkagCSVddQrg04COBKtI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