What's new

Bad, bad compiler

Doomulation

?????????????????????????
Okay I was wondering if you could help me dicipline my compiler a little... it all works well in debug, but in release - once again - it sees the code "unneccesary" and thus removes it. The problem is that it removes my error catching code! Look below...

Code:
	SettingsType type = { 1, this, strKey };
	try
	{
		EnumChildWindows(pDlg->m_hWnd,EnumChildReg,(LPARAM)&type);
	}
	catch(HRESULT hr)
	{
		CString strError = LoadStringRes(IDS_ERROR_REGISTRY_GET);
		if (hr == ERROR_ACCESS_DENIED)
			strError += LoadStringRes(IDS_ERROR_ACCESSDENIED);
		else
			strError += ErrorToString(hr);
		ErrBox(strError);
	}

It removes the entire catch statement. And the functions up ahead DOES throw exceptions if something goes wrong. Is there anything that can be done to prevent this? Save for disabling optimizations for that function of course... that's the last solution I wish to use.

Hmmm... actually, this is the SECOND time I encounter this problem. It happend another time in a function that threw exceptions.

Any ideas?
 

thakis

New member
I'm not sure about this, but I think I read that there may be problems with exceptions being thrown across dll boundaries. You call EnumChildWindows() which is in a separate dll which in turn calls you EnumChildReg(). If EnumChildReg() throws an exception, it _is_ thrown across dll boundaries. Might have been a gcc specific problem, though...

Something different: Perhaps you've disabled exceptions in release builds?
 
OP
Doomulation

Doomulation

?????????????????????????
I'm not sure about this, but I think I read that there may be problems with exceptions being thrown across dll boundaries.
Well, it certainly works in debug builds!

Something different: Perhaps you've disabled exceptions in release builds?
And what setting (or compiler switch) might that be? I know that unwinding for exception is enabled.

Could you move the try/catch into your callback function, EnumChildReg?
Hmmmm... I can try. I'll let you know the results.

UPDATE: It works if I put it into the callback function... but nevertheless, I would wish to know WHY this happens in the first place.
 
Last edited:

Top