[llvm-bugs] [Bug 46690] New: Dead call to std::terminate when using noexcept

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jul 12 06:36:41 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46690

            Bug ID: 46690
           Summary: Dead call to std::terminate when using noexcept
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: federico.kircheis at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Hello, it seems that clang does not optimize some dead code paths when
exceptions are involved.

I know this is common, but since at least GCC is able to optimize this case, I
thought it might have been valuable reporting it.


----
int bar_ex_noexcept(int i) 
    noexcept 
{
    struct foo{};
    try {
        if (i <0){
            throw foo();
        }
        return i;
    } catch(...) {
        return -1;
    }
}
----


GCC output https://godbolt.org/z/5E3jbx (note missing terminate even without
optimizations), and clangs output with -O3: https://godbolt.org/z/1ozsGP


I'm not very good at reading assembly, but strangely removing "noexcept", seem
to produce better code.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200712/25f29dbf/attachment.html>


More information about the llvm-bugs mailing list