<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [clang][avr] clang crashed when compiling cpp program"
   href="https://bugs.llvm.org/show_bug.cgi?id=51287">51287</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[clang][avr] clang crashed when compiling cpp program
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>powerman1st@163.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>clang++ test.cc -O3 -Wall --target=avr -mmcu=atmega328 -S

```
// test.cc
volatile char *p = (volatile char *) 0x4000;

class test {
        int v;
public:
        test(int q): v(q) {}
        int get(void) { return v; }
        ~test() { *p = v; }
};

test obj(4);

```

clang crashed with info 

```
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: ./bin/clang++ a.cc -O3 -Wall --target=avr
-mmcu=atmega328 -S
1.      <eof> parser at end of file
2.      a.cc:11:6: LLVM IR generation of declaration 'obj'
3.      a.cc:11:6: Generating code for declaration 'obj'
 #0 0x00005610f8f6a5cf PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x00005610f8f68490 llvm::sys::CleanupOnSignal(unsigned long)
(./bin/clang+++0x2084490)
 #2 0x00005610f8ec1b58 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
 #3 0x00007f19678ad980 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x00005610f93afd9d (anonymous
namespace)::AVRTargetCodeGenInfo::getGlobalVarAddressSpace(clang::CodeGen::CodeGenModule&,
clang::VarDecl const*) const TargetInfo.cpp:0:0
 #5 0x00005610f92f32fa
clang::CodeGen::CodeGenModule::GetGlobalVarAddressSpace(clang::VarDecl const*)
(./bin/clang+++0x240f2fa)
 #6 0x00005610f9313bc6
clang::CodeGen::CodeGenModule::GetOrCreateLLVMGlobal(llvm::StringRef,
llvm::Type*, unsigned int, clang::VarDecl const*,
clang::CodeGen::ForDefinition_t) (./bin/clang+++0x242fbc6)
 #7 0x00005610f9314919
clang::CodeGen::CodeGenModule::CreateRuntimeVariable(llvm::Type*,
llvm::StringRef) (./bin/clang+++0x2430919)
 #8 0x00005610f9384963 (anonymous
namespace)::ItaniumCXXABI::registerGlobalDtor(clang::CodeGen::CodeGenFunction&,
clang::VarDecl const&, llvm::FunctionCallee, llvm::Constant*)
ItaniumCXXABI.cpp:0:0
 #9 0x00005610f95256d9 EmitDeclDestroy(clang::CodeGen::CodeGenFunction&,
clang::VarDecl const&, clang::CodeGen::ConstantAddress) CGDeclCXX.cpp:0:0
#10 0x00005610f952601e
clang::CodeGen::CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function*,
clang::VarDecl const*, llvm::GlobalVariable*, bool) (./bin/clang+++0x264201e)
#11 0x00005610f95265ab
clang::CodeGen::CodeGenModule::EmitCXXGlobalVarDeclInitFunc(clang::VarDecl
const*, llvm::GlobalVariable*, bool) (./bin/clang+++0x26425ab)
#12 0x00005610f9312b92
clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*,
bool) (./bin/clang+++0x242eb92)
#13 0x00005610f932d8f5
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (./bin/clang+++0x24498f5)
#14 0x00005610f932e13b
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(./bin/clang+++0x244a13b)
#15 0x00005610f9333d2d
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.5272)
CodeGenModule.cpp:0:0
#16 0x00005610f9e7fe91 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
ModuleBuilder.cpp:0:0
#17 0x00005610f9e73cd2
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) crtstuff.c:0:0
#18 0x00005610fab0bc74 clang::ParseAST(clang::Sema&, bool, bool)
(./bin/clang+++0x3c27c74)
#19 0x00005610f9e7dda2 clang::CodeGenAction::ExecuteAction()
(./bin/clang+++0x2f99da2)
#20 0x00005610f9856c21 clang::FrontendAction::Execute()
(./bin/clang+++0x2972c21)
#21 0x00005610f97f4292
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(./bin/clang+++0x2910292)
#22 0x00005610f9922c93
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(./bin/clang+++0x2a3ec93)
#23 0x00005610f7d2700c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (./bin/clang+++0xe4300c)
#24 0x00005610f7d233dd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#25 0x00005610f969f8a5 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#26 0x00005610f8ec2143
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(./bin/clang+++0x1fde143)
#27 0x00005610f96a195e
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
<span class="quote">>, std::__cxx11::basic_string<char, std::char_traits<char>,</span >
std::allocator<char> >*, bool*) const (./bin/clang+++0x27bd95e)
#28 0x00005610f967739a
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const (./bin/clang+++0x279339a)
#29 0x00005610f9677eef
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(./bin/clang+++0x2793eef)
#30 0x00005610f96812d5
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(./bin/clang+++0x279d2d5)
#31 0x00005610f7c9e1ce main (./bin/clang+++0xdba1ce)
#32 0x00007f1966541bf7 __libc_start_main
/build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#33 0x00005610f7d22f5a _start (./bin/clang+++0xe3ef5a)
clang-13: error: clang frontend command failed with exit code 139 (use -v to
see invocation)
clang version 14.0.0 (<a href="mailto:git@github.com">git@github.com</a>:llvm/llvm-project.git
4b563067622d5fd58d5d91de8ce256a1bd36129a)
Target: avr
Thread model: posix
InstalledDir: /mnt/llvm/llvm-0/build-avr/./bin
clang-13: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/a-c7b806.cpp
clang-13: note: diagnostic msg: /tmp/a-c7b806.sh
clang-13: note: diagnostic msg:

********************
```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>