http://llvm.org/bugs/show_bug.cgi?id=22556

            Bug ID: 22556
           Summary: placement new null checks should be optimized away
           Product: clang
           Version: 3.5
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Although the C++ standard address the placement-new/nullptr issue in C++17, it
would seem like the optimizer should be able to optimize away the cost
regardless, at least for vector.

Although placement new could be being called on a nullptr, it will be called
with p[i] where i is some value in [0, size() - 1].

Except for the p[0] case, p[x] where x is in [1, size() - 1] cannot be a
nullptr since pointer arithmetic is undefined behaviour for overflow.

Test-case code:
https://pastebin.mozilla.org/8625250

More information:
http://www.reddit.com/r/cpp/comments/2v3viw/cs_placementnew_prevents_optimalcode_generation/

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to