[LLVMbugs] [Bug 19685] New: constexpr does not work with placement new

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 7 14:51:33 PDT 2014


            Bug ID: 19685
           Summary: constexpr does not work with placement new
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ytj000 at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

#include <stddef.h>
    constexpr void* operator new(size_t, int*) noexcept {
        return nullptr;

    int main() {
        int* p = new (nullptr) int;            // This is Okay
        constexpr int* q = new (nullptr) int;  // gcc works, clang compile
        return *(p = q);

This code compiles with gcc 4.6, 4.7, 4.8, 4.9 and generates correct assembly
(with command line option "-std=c++0x")

It doesn't compile with clang 3.0, 3.2, 3.3, 3.4
(tried "-std=c++1y", "-std=c++11" and "-std=c++0x", none of them works)

Tested by Compiler Explorer: http://goo.gl/bmGtbR

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/20140507/2bbf71f6/attachment.html>

More information about the llvm-bugs mailing list