boost::regex 在调试和发布版本上的行为不同

发布于 2024-09-18 10:54:22 字数 3510 浏览 7 评论 0原文

boost::regex re("^\\s*([_\\w\\.]+)\\s*=\\s*([^\\s]+)$");
if(re.empty()){
  std::cout<<"How is this possible?"<<std::endl;
}

该行打印在我的发布版本中! (调试版本没问题) 使用 MSVC 2008 (vc 9.0) 的

DEBUG 编译器选项:

/Od /I“C:\Program Files\boost\boost_1_44_0”/I“C:\gtest-1.5.0\include”/I“包括”/I“include\EMP”/I“依赖项\EMP\include” /I“依赖项\APR\apr-1.3.3\include”/I“依赖项\solclient_5.0.0.22\include”/I“依赖项\SS66\include”/D“WIN32”/D“_DEBUG”/D“ _CONSOLE" /D "EMP_WIN_X86_32" /D "_iso_stdcpp_" /D "_CRT_SECURE_NO_DEPRECATE" /D "_SECURE_SCL=0" /D "_EMPAPI_STATIC_BUILD" /D "_EMPAPI_STATIC_LINK" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /fp:fast /Fo"调试\" /Fd"调试\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:提示

RELEASE 的编译器选项:

/O2 /Oi /GL /I“C:\Program Files\boost\boost_1_44_0”/I“C:\gtest-1.5.0\include”/I“包括”/I“include\EMP”/I“依赖项\ EMP\include" /I "依赖项\APR\apr-1.3.3\include" /I "依赖项\solclient_5.0.0.22\include" /I "依赖项\SS66\include" /D "WIN32" /D "NDEBUG " /D "_CONSOLE" /D "EMP_WIN_X86_32" /D "_iso_stdcpp_" /D "_CRT_SECURE_NO_DEPRECATE" /D "_SECURE_SCL=0" /D "_EMPAPI_STATIC_BUILD" /D "_EMPAPI_STATIC_LINK" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MD /Gy /fp:fast /Fo"Release\" /Fd"Release\vc90.pdb" /W3 /nologo /c /Zi /TP /errorReport:提示

用于调试的链接器选项:

/OUT:"C:\WorkFlow\cpp_client_library\Debug\cpp_client_library.exe" /INCRMENTAL /NOLOGO /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\APR\apr-1.3.3\Release" /LIBPATH:" C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependency\EMP\lib\win32_vc80" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependency\solclient_5.0.0.22\lib" /LIBPATH:"C:\WorkFlow\cpp_client_library \workflow_client_cpp\dependency\SS66\lib\i86_w32" /LIBPATH:"C:\Program Files\boost\boost_1_44_0\stage\lib" /LIBPATH:"C:\gtest-1.5.0\msvc\gtest\Debug" /MANIFEST /MANIFESTFILE:"调试\cpp_client_library.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\WorkFlow\cpp_client_library\Debug\cpp_client_library.pdb" /SUBSYSTEM :CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT emp.lib libsolclient.lib Tipc.lib tutil.lib gtestd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

RELEASE 的链接器选项:

/OUT:"C:\WorkFlow\cpp_client_library\Release\cpp_client_library.exe" /INCRMENTAL:NO /NOLOGO /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\APR\apr-1.3.3\Release" /LIBPATH :"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\EMP\lib\win32_vc80" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\solclient_5.0.0.22\lib" /LIBPATH:"C:\WorkFlow \cpp_client_library\workflow_client_cpp\dependency\SS66\lib\i86_w32" /LIBPATH:"C:\Program Files\boost\boost_1_44_0\stage\lib" /LIBPATH:"C:\gtest-1.5.0\msvc\gtest\Release" /MANIFEST /MANIFESTFILE:"Release\cpp_client_library.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\WorkFlow\cpp_client_library\Release\cpp_client_library.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT emp.lib libsolclient.lib Tipc.lib tutil.lib gtest.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

boost::regex re("^\\s*([_\\w\\.]+)\\s*=\\s*([^\\s]+)$");
if(re.empty()){
  std::cout<<"How is this possible?"<<std::endl;
}

That line prints in my release builds! (The debug builds are fine)
Working with MSVC 2008 (vc 9.0)

Compiler options for DEBUG:


/Od /I "C:\Program Files\boost\boost_1_44_0" /I "C:\gtest-1.5.0\include" /I "include" /I "include\EMP" /I "dependencies\EMP\include" /I "dependencies\APR\apr-1.3.3\include" /I "dependencies\solclient_5.0.0.22\include" /I "dependencies\SS66\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "EMP_WIN_X86_32" /D "_iso_stdcpp_" /D "_CRT_SECURE_NO_DEPRECATE" /D "_SECURE_SCL=0" /D "_EMPAPI_STATIC_BUILD" /D "_EMPAPI_STATIC_LINK" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /fp:fast /Fo"Debug\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt

Compiler options for RELEASE:


/O2 /Oi /GL /I "C:\Program Files\boost\boost_1_44_0" /I "C:\gtest-1.5.0\include" /I "include" /I "include\EMP" /I "dependencies\EMP\include" /I "dependencies\APR\apr-1.3.3\include" /I "dependencies\solclient_5.0.0.22\include" /I "dependencies\SS66\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "EMP_WIN_X86_32" /D "_iso_stdcpp_" /D "_CRT_SECURE_NO_DEPRECATE" /D "_SECURE_SCL=0" /D "_EMPAPI_STATIC_BUILD" /D "_EMPAPI_STATIC_LINK" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MD /Gy /fp:fast /Fo"Release\" /Fd"Release\vc90.pdb" /W3 /nologo /c /Zi /TP /errorReport:prompt

Linker Options for DEBUG:


/OUT:"C:\WorkFlow\cpp_client_library\Debug\cpp_client_library.exe" /INCREMENTAL /NOLOGO /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\APR\apr-1.3.3\Release" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\EMP\lib\win32_vc80" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\solclient_5.0.0.22\lib" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\SS66\lib\i86_w32" /LIBPATH:"C:\Program Files\boost\boost_1_44_0\stage\lib" /LIBPATH:"C:\gtest-1.5.0\msvc\gtest\Debug" /MANIFEST /MANIFESTFILE:"Debug\cpp_client_library.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\WorkFlow\cpp_client_library\Debug\cpp_client_library.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT emp.lib libsolclient.lib tipc.lib tutil.lib gtestd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

Linker Options for RELEASE:


/OUT:"C:\WorkFlow\cpp_client_library\Release\cpp_client_library.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\APR\apr-1.3.3\Release" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\EMP\lib\win32_vc80" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\solclient_5.0.0.22\lib" /LIBPATH:"C:\WorkFlow\cpp_client_library\workflow_client_cpp\dependencies\SS66\lib\i86_w32" /LIBPATH:"C:\Program Files\boost\boost_1_44_0\stage\lib" /LIBPATH:"C:\gtest-1.5.0\msvc\gtest\Release" /MANIFEST /MANIFESTFILE:"Release\cpp_client_library.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\WorkFlow\cpp_client_library\Release\cpp_client_library.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT emp.lib libsolclient.lib tipc.lib tutil.lib gtest.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别念他 2024-09-25 10:54:22

我改用 Visual Studio 2005,问题消失了,但现在在应用程序接近尾声时出现异常:

myApp.exe 中 0x0042d935 处出现未处理的异常:0xC0000005:访问冲突读取位置 0xe06d7390。

调用堆栈是

kernel32.dll!7c812afb()
[下面的框架可能不正确和/或丢失,没有为 kernel32.dll 加载任何符号]
kernel32.dll!7c812afb()
msvcp80.dll!7c421201()
msvcp80.dll!7c42394d()
msvcp80.dll!7c423958()
msvcr80.dll!78158e89()
myApp.exe!std::_Tree,std::分配器>,std::less,std::分配器,std::分配器> > >,0> >::erase(std::_Tree,std::allocator >,std::less,std::allocator,std::allocator > > > >,0 > >::iterator _Where={. ..}) 759 行
msvcr80.dll!78134c39()
myApp.exe!std::_Tree,std::分配器>,std::less,std::分配器,std::分配器> > >,0> >::erase(std::_Tree,std::allocator >,std::less,std::allocator,std::allocator > > > >,0 > >::iterator _First={. ..}, std::_Tree,std::allocator >,std::less,std::allocator,std::allocator > >,0 >::iterator _Last={... }) 第 926 行 + 0x4f 字节
myApp.exe!boost::re_detail::w32_regex_traits_implementation::~w32_regex_traits_implementation() + 0xc0 字节
myApp.exe!boost::detail::sp_counted_impl_p >::dispose() + 0xf 字节
myApp.exe!std::list const >,unsigned long const *>,std::allocator const >,unsigned long const *> > >::clear() + 0x3e 字节
myApp.exe!boost::object_cache >::data::~data() + 0x6b 字节
msvcr80.dll!781319d8()
msvcr80.dll!78131a4b()
myApp.exe!__tmainCRTStartup() 第 603 行
kernel32.dll!7c817077()

I moved to using visual studio 2005 and the problem went away but I am now getting an exception near the end of the application:

Unhandled exception at 0x0042d935 in myApp.exe: 0xC0000005: Access violation reading location 0xe06d7390.

The call stack is

kernel32.dll!7c812afb()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
kernel32.dll!7c812afb()
msvcp80.dll!7c421201()
msvcp80.dll!7c42394d()
msvcp80.dll!7c423958()
msvcr80.dll!78158e89()
myApp.exe!std::_Tree,std::allocator >,std::less,std::allocator,std::allocator > > >,0> >::erase(std::_Tree,std::allocator >,std::less,std::allocator,std::allocator > > >,0> >::iterator _Where={...}) Line 759
msvcr80.dll!78134c39()
myApp.exe!std::_Tree,std::allocator >,std::less,std::allocator,std::allocator > > >,0> >::erase(std::_Tree,std::allocator >,std::less,std::allocator,std::allocator > > >,0> >::iterator _First={...}, std::_Tree,std::allocator >,std::less,std::allocator,std::allocator > > >,0> >::iterator _Last={...}) Line 926 + 0x4f bytes
myApp.exe!boost::re_detail::w32_regex_traits_implementation::~w32_regex_traits_implementation() + 0xc0 bytes
myApp.exe!boost::detail::sp_counted_impl_p >::dispose() + 0xf bytes
myApp.exe!std::list const >,unsigned long const *>,std::allocator const >,unsigned long const *> > >::clear() + 0x3e bytes
myApp.exe!boost::object_cache >::data::~data() + 0x6b bytes
msvcr80.dll!781319d8()
msvcr80.dll!78131a4b()
myApp.exe!__tmainCRTStartup() Line 603
kernel32.dll!7c817077()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文