diff --git a/compiler/optdeadstore.pas b/compiler/optdeadstore.pas
index 2c325f0213..15cc52658c 100644
--- a/compiler/optdeadstore.pas
+++ b/compiler/optdeadstore.pas
@@ -79,7 +79,7 @@ unit optdeadstore;
                     ((a.right.nodetype in [niln,stringconstn,pointerconstn,setconstn,guidconstn]) or
                      ((a.right.nodetype=ordconstn) and not(cs_check_range in current_settings.localswitches)) or
                      ((a.right.nodetype=realconstn) and not(cs_ieee_errors in current_settings.localswitches)) or
-                    ((cs_opt_dead_values in current_settings.optimizerswitches) and not(might_have_sideeffects(a.right)))
+                    ((cs_opt_dead_values in current_settings.optimizerswitches) and not(might_have_sideeffects(a.right,[mhs_exceptions])))
                    ) then
                   begin
                     redundant:=not(assigned(a.successor)) or not(DFASetIn(a.successor.optinfo^.life,a.left.optinfo^.index));