G
Guest
VC++ .NET 2003: Access violation with /O2 compiler switch; no AV with /O
Hi
I'm in the process of narrowing down a problem, and I have reduced the code involved to the following
If someone could do the following and verify what I am seeing (and offer any insight!), I would appreciate it
Simply create a new "Win32 Console Project" in VC++ .NET 2003. On the "Application Settings" page, check the "Empty project" box. Click "Finish"
Add a new C++ source file, and paste in the following code
//=================
#include <strstream
#include <malloc.h
void Fn( void
_alloca( 100 )
std:strstream oss
oss << std::ends
oss.str()
oss.freeze( false )
throw std::string()
int main( void
tr
Fn()
catch( std::string&
return 0
//=================
I know the code doesn't make a whole lot of sense as it stands, but I am trying to reduce the code required to repro the problem to a minimum. When I build a "Release" build of the project (with the default project settings, which includes the default /O2, or "Maximize Speed" optimization) and run it, I get an AV in ostrstream::~ostrstream ("Access violation reading location 0x00000004"). Same result with /Ox ("Full Optimization"). However, if I change the optimization to /O1 ("Minimize Size") or /Od ("Disable [Optimizations]"), the code runs "just fine" (no AV)
If I do the same thing with VC++ .NET 2002, the code runs "just fine" with all optimization settings (/Od, /O1, /O2, /Ox)
Any thoughts?
Hi
I'm in the process of narrowing down a problem, and I have reduced the code involved to the following
If someone could do the following and verify what I am seeing (and offer any insight!), I would appreciate it
Simply create a new "Win32 Console Project" in VC++ .NET 2003. On the "Application Settings" page, check the "Empty project" box. Click "Finish"
Add a new C++ source file, and paste in the following code
//=================
#include <strstream
#include <malloc.h
void Fn( void
_alloca( 100 )
std:strstream oss
oss << std::ends
oss.str()
oss.freeze( false )
throw std::string()
int main( void
tr
Fn()
catch( std::string&
return 0
//=================
I know the code doesn't make a whole lot of sense as it stands, but I am trying to reduce the code required to repro the problem to a minimum. When I build a "Release" build of the project (with the default project settings, which includes the default /O2, or "Maximize Speed" optimization) and run it, I get an AV in ostrstream::~ostrstream ("Access violation reading location 0x00000004"). Same result with /Ox ("Full Optimization"). However, if I change the optimization to /O1 ("Minimize Size") or /Od ("Disable [Optimizations]"), the code runs "just fine" (no AV)
If I do the same thing with VC++ .NET 2002, the code runs "just fine" with all optimization settings (/Od, /O1, /O2, /Ox)
Any thoughts?