gpt4 book ai didi

c++ - 从 throw 表达式中抛出异常

转载 作者:太空宇宙 更新时间:2023-11-03 10:22:45 24 4
gpt4 key购买 nike

<分区>

在 clang 上运行以下代码会出现段错误

#include <stdexcept>

int foo() {
throw std::runtime_error{{}};
}

int main() {
try {
throw foo();
} catch (...) {}
}

https://wandbox.org/permlink/PrLRJyHq9o2K5Eez

但这在 gcc 上运行良好 https://wandbox.org/permlink/ORV2B5RfTl22RKxo .阅读标准似乎并没有明确说这种事情是无效的。这里clang错了吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com