gpt4 book ai didi

c++ - 关于 Javascript 引擎错误的问题

转载 作者:行者123 更新时间:2023-11-28 04:11:28 26 4
gpt4 key购买 nike

我有一个关于 Javascript 引擎错误的问题。这可能是一个非常具体的问题,之前有没有人看到过这个错误?可以帮忙看看吗?

这是错误信息:

483e709e1e8:buildDirARNJavaScriptEngine mac$ make install
Scanning dependencies of target JavaScriptEngine
[ 8%] Building CXX object JavaScriptEngineImpl/src/CMakeFiles/JavaScriptEngine.dir/JavaScriptEngineImpl.cpp.o
[ 16%] Building CXX object JavaScriptEngineImpl/src/CMakeFiles/JavaScriptEngine.dir/JavaScriptEngineImplDuktape.cpp.o
/Users/mac/Documents/WorkSpace/JavaScriptEngine/JavaScriptEngineImpl/src/JavaScriptEngineImplDuktape.cpp:130:13: error: '~DuktapeStackVerification' has
a non-throwing exception specification but can still throw [-Werror,-Wexceptions]
throw utils::Exception(errorMsg);
^
/Users/mac/Documents/WorkSpace/JavaScriptEngine/JavaScriptEngineImpl/src/JavaScriptEngineImplDuktape.cpp:123:6: note: destructor has a implicit
non-throwing exception specification
~DuktapeStackVerification() {
^
1 error generated.
make[2]: *** [JavaScriptEngineImpl/src/CMakeFiles/JavaScriptEngine.dir/JavaScriptEngineImplDuktape.cpp.o] Error 1
make[1]: *** [JavaScriptEngineImpl/src/CMakeFiles/JavaScriptEngine.dir/all] Error 2
make: *** [all] Error 2

这是我构建的内容/方式:

a483e709e1e8:buildDirJavaScriptEngine mac$ cmake ../JavaScriptEngine/ -DWITH_DUKTAPE=ON -DWITH_V8=ON
Creating the build directory for the JavaScriptEngineLibrary with build type: DEBUG
CMAKE_INSTALL_PREFIXis=====/Users/mac/Documents/WorkSpace/buildDirJavaScriptEngine/../Artifacts
====> Exporting Target Tuple using /Users/mac/Documents/WorkSpace/JavaScriptEngine/../BuildCommons/cmake/config.guess
====> Target Tuple is x86_64-apple-darwin18.7.0
Dependencies SHARED +++++ /Users/mac/Documents/WorkSpace/Artifacts/lib/libLogger.dylib;-Wl,-rpath,/Users/mac/Documents/WorkSpace/buildDirJavaScriptEngine/../Artifacts/lib
Dependencies SHARED +++++ /Users/mac/Documents/WorkSpace/Artifacts/lib/libException.dylib;-Wl,-rpath,/Users/mac/Documents/WorkSpace/buildDirJavaScriptEngine/../Artifacts/lib
Dependencies SHARED +++++ /Users/mac/Documents/WorkSpace/Artifacts/lib/libJsonContainer.dylib;-Wl,-rpath,/Users/mac/Documents/WorkSpace/buildDirJavaScriptEngine/../Artifacts/lib
Dependencies +++++ /Users/mac/Documents/WorkSpace/buildDirJavaScriptEngine/../Artifacts/include;/Users/mac/Documents/WorkSpace/buildDirJavaScriptEngine/../Artifacts/include/v8
Dependencies SHARED +++++ /Users/mac/Documents/WorkSpace/Artifacts/lib/libDuktape.dylib;-Wl,-rpath,/Users/mac/Documents/WorkSpace/buildDirJavaScriptEngine/../Artifacts/lib
Dependencies STATIC +++++ /Users/mac/Documents/WorkSpace/Artifacts/lib/libv8_monolith.a
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/mac/Documents/WorkSpace/buildDirJavaScriptEngine

这段源码在提示:

~DuktapeStackVerification() {
m_endStackIndex = duk_get_top_index(m_ctx);
if (m_beginStackIndex != m_endStackIndex) {
std::string errorMsg = "beginStackIndex: " + std::to_string(m_beginStackIndex) +
" endStackIndex: " + std::to_string(m_endStackIndex) +
" func: " + m_func;
LOG_ERROR(errorMsg, JAVASCRIPTENGINE_IMPL_DUKTAPE_MODULE_NAME);
throw utils::Exception(errorMsg);
}
}

最佳答案

编译器实际上是在告诉你发生了什么:

error: '~DuktapeStackVerification' has a non-throwing exception specification but can still throw

note: destructor has a implicit non-throwing exception specification

对于其他背景,您可以搜索诸如“C++ throw destructor”之类的术语,您会发现(例如 herehere )从 C++11 开始,析构函数被隐式标记为 nothrow( true),因为从析构函数中抛出通常被认为是危险的。要覆盖该默认值,您必须将析构函数显式注释为 noexcept(false) —— 或者只是停止在那里抛出,并使用其他一些机制来指示问题。无论如何,它看起来像是针对编程错误的断言,因此立即终止可能与抛出异常一样好。

关于c++ - 关于 Javascript 引擎错误的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57683650/

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