Optimizer ignores try-catch block 
Author Message
 Optimizer ignores try-catch block

This code works fine when compiled without optimizations, but when optimized, the exception thrown by IsAppThemed when delay-loading uxtheme.dll fails doesn't get caught:

try
{
 OutputDebugString(_T("Checking if app is themed\n"));
 m_themed = IsAppThemed() && IsThemeActive() &&
  GetThemeAppProperties() & STAP_ALLOW_NONCLIENT;
 OutputDebugString(_T("Checked if app is themed\n"));

Quote:
}

catch(...)
{
 OutputDebugString(_T("uxtheme not loaded yet\n"));
 return false;

Quote:
}

Do I have any other options besides disabling optimizations?

Thanks,

Christian Studer
http://www.*-*-*.com/



Fri, 21 Jan 2005 14:02:35 GMT  
 Optimizer ignores try-catch block
As you are trying to catch SEH exceptions with a catch(...) you need to
compile with -EHa (it sounds like you are either currently using -EHs
or -EHsc.)

If the rest of your code isn't using catch(...) for SEH exceptions, then I
would encourage you to avoid starting that, instead using a __try/__except
block to catch the SEH exceptions that the delay loading code will raise on
failures.


This code works fine when compiled without optimizations, but when
optimized, the exception thrown by IsAppThemed when delay-loading
uxtheme.dll fails doesn't get caught:

try
{
 OutputDebugString(_T("Checking if app is themed\n"));
 m_themed = IsAppThemed() && IsThemeActive() &&
  GetThemeAppProperties() & STAP_ALLOW_NONCLIENT;
 OutputDebugString(_T("Checked if app is themed\n"));

Quote:
}

catch(...)
{
 OutputDebugString(_T("uxtheme not loaded yet\n"));
 return false;

Quote:
}

Do I have any other options besides disabling optimizations?

Thanks,

Christian Studer
http://www.realtimesoft.com



Fri, 21 Jan 2005 14:36:51 GMT  
 Optimizer ignores try-catch block
Thanks, using /EHa fixed the problem.

Christian Studer
http://www.realtimesoft.com


Quote:
> As you are trying to catch SEH exceptions with a catch(...) you need to
> compile with -EHa (it sounds like you are either currently using -EHs
> or -EHsc.)

> If the rest of your code isn't using catch(...) for SEH exceptions, then I
> would encourage you to avoid starting that, instead using a __try/__except
> block to catch the SEH exceptions that the delay loading code will raise on
> failures.



Sat, 22 Jan 2005 04:08:40 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. The if ~ else block in try~catch block

2. TRY-CATCH vs. try-catch

3. try/catch VS TRY/CATCH

4. try catch block

5. does atl support try..catch block?(empty inside)

6. Overhead of try-catch blocks?

7. /Og causes intermittent omission of try..catch block

8. nested try/catch block and _set_se_translator

9. try{} catch{} block and Global Optimization

10. Error processing using try-catch blocks

11. can I nest try/catch blocks?

12. Try catch blocks - can multiple methods share a single try/catch combination?

 

 
Powered by phpBB® Forum Software