[llvm-bugs] [Bug 37482] New: Condition that leads to __builtin_unreachable() is not propagated to other branches

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 16 02:52:59 PDT 2018


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

            Bug ID: 37482
           Summary: Condition that leads to __builtin_unreachable() is not
                    propagated to other branches
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: sergei.a.izmailov at gmail.com
                CC: llvm-bugs at lists.llvm.org

Clang is unable to optimize the next code: 

#include <stdexcept>
const double& safe_deref(double* a) {
    if (a==nullptr) { // expansion of GSL Ensures macro with
GSL_UNENFORCED_ON_CONTRACT_VIOLATION
         __builtin_unreachable();
    }
    if (a==nullptr) { 
        throw std::runtime_error("error");
    }
    return *a;
}

GCC optimize out both "if" statements, see https://godbolt.org/g/4hSgAA

-- 
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/20180516/8777a510/attachment.html>


More information about the llvm-bugs mailing list