发现loki C++库的一个bug

mujiok2003 mujiok2003 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
FixedAllocator::FixedAllocator(std::size_t blockSize)
: blockSize_(blockSize)
, allocChunk_(0)
, deallocChunk_(0)
{
assert(blockSize_ > 0);

prev_ = next_ = this;

std::size_t numBlocks = DEFAULT_CHUNK_SIZE / blockSize;
if (numBlocks > UCHAR_MAX) numBlocks = UCHAR_MAX;
else if (numBlocks == 0) numBlocks = 8 * blockSize;
//when numBlocks equals zero,the assert statement
// "assert(numBlocks_ == numBlocks);" always fails

numBlocks_ = static_cast<unsigned char>(numBlocks);
assert(numBlocks_ == numBlocks);
}

如注释所所示,当参数blockSize>DEFAULT_CHUNK_SIZE时,最后一条断言始终失败,
...全文

相关推荐

Loki库源码(泛型模式C++库)

Loki is the name of a C++ software library written by Andrei Alexandrescu as part of his book Modern C++ Design.   The library makes extensive use of C++ template metaprogramming and implements several commonly used tools: typelist, functor, singleton, smart pointer, object factory, visitor and multimethods.   Originally the library was only compatible with two of the most standard conforming C++ compilers (CodeWarrior and Comeau C/C++): later efforts have made it usable with a wide array of compilers (including older Visual C++ 6.0, Borland C++ Builder 6.0, and GCC). Compiler vendors used Loki as a compatibility benchmark, further increasing the number of compliant compilers.   Maintenance and further development of Loki has been continued through an open-source community led by Peter Kümmel and Richard Sposato as a Sourceforge project.Ongoing contributions by many people have improved the overallrobustness and functionality of the library. Loki is not tied to thebook anymore as it already has a lot of new components (e.g. -StrongPtr, Printf, and Scopeguard). Loki inspired similar tools andfunctionality now also present in the [1][2]Boost library collection. [1] http://en.wikipedia.org/wiki/Loki_(C%2B%2B) [2] http://loki-lib.sourceforge.net/

rendao0563

(c++设计新思维的库)loki

(c++设计新思维的库)loki (c++设计新思维的库)loki (c++设计新思维的库)loki

wangtengkl

stl和loki库

stl和loki库源代码 stl和loki库

leaker

loki库模板元编程的经典库

享誉C++社区的模板元编程的经典库:Loki库源码

shouhouren

STL源码及讲解与LOKI库源码

STL源码及讲解与LOKI库源码,C++高级编程修炼必备

numenshane1
评论 3
收藏 已收藏
分享
返回顶部
mujiok2003
C++ 语言 65,214 成员 250,514 内容