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: dcough...@apple.com
          Reporter: cassio.n...@gmail.com
                CC: dcough...@apple.com, llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to