[llvm-bugs] [Bug 35573] New: Calling array new with a negative size should be checked in C++14 mode
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Dec 8 02:14:42 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35573
Bug ID: 35573
Summary: Calling array new with a negative size should be
checked in C++14 mode
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++14
Assignee: unassignedclangbugs at nondot.org
Reporter: t.p.northover at gmail.com
CC: llvm-bugs at lists.llvm.org
When emitting code for a new array expression we check whether the array size
is negative in C++98 and C++11 mode, but not from C++14 onwards. E.g.
char *foo(int a) {
return new char[a];
}
$ clang++ tmp.cpp -std=c++11 -S -o- -emit-llvm -Os
define noalias nonnull i8* @_Z3fooi(i32 %a) local_unnamed_addr #0 {
entry:
%0 = sext i32 %a to i64
%1 = icmp sgt i64 %0, -1
%2 = select i1 %1, i64 %0, i64 -1
%call = tail call i8* @_Znam(i64 %2) #2
ret i8* %call
}
$ clang++ tmp.cpp -std=c++14 -S -o- -emit-llvm -Os
define noalias nonnull i8* @_Z3fooi(i32 %a) local_unnamed_addr #0 {
entry:
%conv = sext i32 %a to i64
%call = tail call i8* @_Znam(i64 %conv) #2
ret i8* %call
}
--
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/20171208/9b7cfa9b/attachment.html>
More information about the llvm-bugs
mailing list