小编o2g*_*2gy的帖子

超出 C++ 的界限和未定义的行为

我知道在 C++ 中访问缓冲区边界是未定义的行为。
这是来自 cppreference 的示例:

int table[4] = {};
bool exists_in_table(int v)
{
    // return true in one of the first 4 iterations or UB due to out-of-bounds access
    for (int i = 0; i <= 4; i++) {
        if (table[i] == v) return true;
    }
    return false;
}
Run Code Online (Sandbox Code Playgroud)

但是,我在 c++ 标准中找不到相应的段落。
谁能指出我在标准中解释这种情况的具体段落?

c++ undefined-behavior language-lawyer

6
推荐指数
1
解决办法
240
查看次数

boost::asio 是否使用 ssl 会话缓存?

例如,我开发了电子邮件客户端。我知道某些服务器(例如imap.gmail.com)会缓存 SSL 会话。所以我想重用 SSL 会话(来自我这边的缓存)来减少服务器负载。

我使用boost::asio作为网络引擎。问题是:

  1. 如果boost::asio::ssl::stream不使用 ssl-session-cache,我该如何启用它?
  2. 如果boost::asio::ssl::stream使用 ssl-session-cache,我该如何关闭它?:)

c++ ssl boost

5
推荐指数
1
解决办法
1034
查看次数

标签 统计

c++ ×2

boost ×1

language-lawyer ×1

ssl ×1

undefined-behavior ×1