[llvm-bugs] [Bug 28811] New: nullptr conversion to bool should not be true

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 2 01:38:38 PDT 2016


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

            Bug ID: 28811
           Summary: nullptr conversion to bool should not be true
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: westion717 at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

typedef decltype(nullptr) nullptr_t;

nullptr_t x1 = x1;

nullptr_t x2(x2);

static const nullptr_t x3[] = {x3[0]};

nullptr_t x4 = !x4 ? x4 : (nullptr_t)0;

template <class T> struct A {
        static T x;
};
template <class T> T A<T>::x = x;
A<nullptr_t> x5;

struct B {
        nullptr_t x;
        B() : x(x) {}
};

nullptr_t& f()
{
        static nullptr_t x = x;
        return x;
}

int main()
{
        if (x1 || x2 || x3[0] || x4 || x5.x)
                return 1;

        if (B().x || f()){

        __builtin_printf("----\n");
                return 1;
    }


        const nullptr_t x[] = {[&x]{return x[0];}()};
        if (x[0])
                return 1;

        return 0;
}

expected return 0;
actual return 1;

-- 
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/20160802/cbc19408/attachment.html>


More information about the llvm-bugs mailing list