[llvm-bugs] [Bug 43685] New: Constexpr new: uncatched UB in constant context

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 16 03:52:20 PDT 2019


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

            Bug ID: 43685
           Summary: Constexpr new: uncatched UB in constant context
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zamazan4ik at tut.by
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

For the following code: 

#include <iostream>
#include <deque>

int main()
{
    constexpr auto a = []()
            {
                std::deque<int> d;
                d.push_back(42);
                d.pop_back();
                return d.front();
            }();
    std::cout << a << std::endl;
    return 0;
}

instead of compilation error Clang(trunk) compiles successfully and the program
prints 42. If you add one more d.pop_back() compiler correctly recognizes UB
and stops compilation. Do I miss anything?

Preprocessed file: https://gofile.io/?c=XE2s96

Constexpr deque implementation:
https://github.com/ZaMaZaN4iK/llvm-project/tree/feature/deque_constexpr

Latest commit in llvm-project: 8af5ada09319e5a021d57a1a03715b2fd022e415

-- 
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/20191016/0580a332/attachment.html>


More information about the llvm-bugs mailing list