[LLVMbugs] [Bug 21321] locale scan-build triggers CERT MEM04 zero-length allocation error
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Oct 21 09:34:48 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=21321
Marshall Clow (home) <mclow.lists at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Marshall Clow (home) <mclow.lists at gmail.com> ---
The C++ standard explicitly allows zero-sized allocations
(Quoting from N3937, but it's the same in C++03 and C++11)
See 3.7.4.1/2:
Even if the size of the space requested is zero, the request can fail. If the
request succeeds, the value returned shall be a non-null pointer value (4.10)
p0 different from any previously returned value p1, unless that value p1 was
subsequently passed to an operator delete. The effect of indirecting through a
pointer returned as a request for zero size is undefined. (36)
[ bottom of page ]
36) The intent is to have operator new() implementable by calling std::malloc()
or std::calloc(), so the rules are sub-stantially the same. C++ differs from C
in requiring a zero request to return a non-null pointer.
Note: I'd be happy if you were to open a bug against scan-build for this issue
:-)
--
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/20141021/7c709165/attachment.html>
More information about the llvm-bugs
mailing list