Unsupported operation

Gosh, I feel so amateurish today... For years I've been succesfully programming MFC apps where the Debug and Release builds behaved identically. They weren't always doing the right thing - but at least they did the same thing. Now suddenly, I've got an app whose Debug version works but whose Release version doesn't... :o I thought I'd passed that stage years ago. :(

It's not even an error that I recognise. I don't see the usual "This application has had to shut down" or "The address 0xNNNNNNNN could not be read" etc. My app gets shut down and I get a dialog saying "An unsupported operation was attempted."

After a bit of fiddling this morning I've discovered that disabling optimizations makes the problem go away (my Release builds are normally optimized for maximum speed). Would this give any clue as to where the problem might be?
[902 byte] By [John E] at [2007-11-20 11:57:49]
# 1 Re: Unsupported operation
Sounds to me like you are optimizing for a different Processor than you are actually running on. Thus the executable contains processor instructions (e.g. SSE3) that are not available on your processor. Check your optimzation settings.
treuss at 2007-11-11 4:01:56 >
# 2 Re: Unsupported operation
Thanks treuss - but since I first posted I've come to realise that the optimization thing is probably a red herring. The last thing I added to this project was an archiving system using the MFC class CArchive (which I've never used before). If I comment out the bits that save & load archives, the problem disappears - so there's probably something in CArchive that I've misunderstood. Thanks for the suggestion though... :thumb:
John E at 2007-11-11 4:02:56 >
# 3 Re: Unsupported operation
Hmmm... admittedly I'm not very experienced with CArchive but I can't quite see what I've done wrong. In the code below, CArchive has been successfully opened with nMode set to CArchive::load

void CSeasonMapper::Serialize(CArchive& archive)
{
CDialog::Serialize(archive);

if (archive.IsStoring())
{
// Not relevant
}
else
{
DWORD dwVersion;
WORD wSeason;
WORD wIsSeasonal;
UINT uSchema;
CString strProjectTitle;

archive >> uSchema; // This gets the version number of the archive
archive >> wSeason;
archive >> wIsSeasonal;

// Let's see if this is a version we understand
switch (dwVersion = uSchema & (~VERSIONABLE_SCHEMA)) {
case 5: // We found a Version 5 archive
// Let's try and load the data from it
try
{
// Retrieve the archive's title
archive >> strProjectTitle; // Fails here

// Rest of stuff
}
catch (CFileException* pfx)
{
// ...
}
catch (CArchiveException* pax)
{
// ...
}
catch (...)
{
// Exception gets caught here
}

// More cases
}
}
}The code fails (in Release mode) when I try to read a string from the archive. It works in Debug mode and strProjectTitle contains the expected string. Note that three earlier statements have already read from the archive so I assume that reading (generally) is working.

I'm using the >> operator to read this string and in Debug mode this does seem to work. But I noticed that CArchive actually has a specific ReadString() member function. Should I be using that??

Also, is there any way to find out what type of exception got caught?
John E at 2007-11-11 4:03:55 >