Hi Udo, thank you for your work-around!
I can confirm your observations (on Win7 64bit, Mathematica 10.0.2.0). Your work-around works like a charm.
It also works with a throwing error handler:
In[351]:= Remove[func27]
func27 = Compile[{{v, _Real}}, Sqrt[v - 27], "RuntimeOptions" -> {"RuntimeErrorHandler" -> Function[Throw[$Failed]]}];
If[True,(*if True unfreak the error handler, otherwise get always $Failed below*)
Catch[func27[#]] & /@ {1, 27}
];
(*works if True above*)
Catch[func27[#]] & /@ Range[23, 30]
Out[354]= {$Failed, $Failed, $Failed, $Failed, 0., 1., 1.41421, 1.73205}
The work-around works also using Check:
In[313]:=Remove[func28]
func28 = Compile[{{v, _Real}}, Block[{r}, r = Sqrt[v - 28]]];
If[True,(*if True unfreak the error handler, otherwise get complex numbers below after 3x"error"*)
func28[#] & /@ {1, 28}
];
Map[Check[func28[#], "error"] &, Range[24, 30]]
Out[316]= {"error", "error", "error", "error", 0., 1., 1.41421}
I have sent a bug report to Wolfram Support.
Andreas