[llvm-bugs] [Bug 49260] New: Better error message when missing #include<new> and using placement new

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 19 00:48:48 PST 2021


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

            Bug ID: 49260
           Summary: Better error message when missing #include<new> and
                    using placement new
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kirshamir at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Use of placement new requires  #include <new>
Without this include the error message is something like:

error: no matching function for call to 'operator new'
      new (this) A(other);
      ^   ~~~~~~
note: candidate function not viable: no known conversion from 'A *' to
'std::align_val_t' for 2nd argument
note: candidate function not viable: requires 1 argument, but 2 were provided

Many std headers have #include <new> thus users just usually write placement
new without a special include and everything works fine, but when code moves
around above error message may just pop up.

A better error might be:

error: no matching function for call to 'operator new'
      new (this) A(other);
      ^   ~~~~~~

Note: use of placement new requires #include <new>

...

-- 
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/20210219/5128e668/attachment.html>


More information about the llvm-bugs mailing list