[llvm-bugs] [Bug 44693] New: False positive on calling new(std::size_t, std::align_val_t)
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jan 28 01:56:24 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=44693
Bug ID: 44693
Summary: False positive on calling new(std::size_t,
std::align_val_t)
Product: clang
Version: 7.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Static Analyzer
Assignee: dcoughlin at apple.com
Reporter: cassio.neri at gmail.com
CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org
Consider:
struct X {
alignas(32) char c;
};
int main() {
X* p = new X; // #1
delete p;
}
compiled with
scan-build clang++ -g -std=c++17 main.cpp
yields warning: Function taking 2 arguments is called with fewer (1)
X* p = new X;"
^~~~~
Since X is an over-aligned type, in C++17 the new expression in #1 makes the
compiler to call operator new(std::size_t, std::align_val_t). It seems the
static analyzer believes the compiler behaves as per C++14 and makes a call to
new(std::size_t).
At least the warning could output a more informative message mentioning
over-alignment.
--
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/20200128/f1b21169/attachment-0001.html>
More information about the llvm-bugs
mailing list