Does the RuntimeOptions -> "EvaluateSymbolically" -> False work for "1-x"

I would like to pass a CompiledFunction to a FindRoot algorithm and therefore I use the option RuntimeOptions -> "EvaluateSymbolically" -> False. For example:

ff = Compile[x, x, RuntimeOptions -> "EvaluateSymbolically" -> False]


As expected and as demanded, the function does not evaluate when passing a non-numerical argument:

ff[a]

CompiledFunction[..][a]


However, when passing "1-a" the following warning appears:

ff[1 - a]

CompiledFunction::cfsa: Argument 1-a at position 1 should be a machine-size real number. >>


My question: Does MMA now use an uncompiled evaluation when returning:

ff[1-a]/.a->2


Unfortunately, I cannot relabel variables in my setup, due to the large number of occurrences of 1-a

• I'm inclined to say that the warning CompiledFunction::cfsa is unintended, i.e. it's a bug. Since ff[1-a] still returns a CompiledFunction object, f[1-a]/.a->2 should evaluate using compiled code. Oct 1, 2016 at 12:25

This is just a warning message, which is issued because 1 - a is not a variable (it is a normal expression with head Plus) and can be suppressed e.g. by setting "WarningMessages" -> False.
ff[1 - a] /. a -> 2

which can be checked by setting the "RuntimeErrorHandler" option.
• +1, but it's not particularly obvious what counts as a "variable": ff[Sin[x]], ff[BesselJ[0, x]], ff[Sin[-x]], ff[BesselJ[1/2, x]] -- the latter two giving warnings, presumably because they have the head Times (after evaluating). It seems to be whatever expr is accepted by D in D[1, expr]. (Silly example: D[1, Plot[x, {x, 0, 1}]].) Oct 1, 2016 at 17:29
• @MichaelE2 Yes, D (and several other functions) use the same test to determine what might be a variable. It is a heuristic that explicitly forbids several common heads (including List, Plus, Times, Equal, And, ConditionalExpression etc.) but anything else is let through, and no, it hasn't been taught to care about Sin, BesselJ or Plot. Oct 2, 2016 at 16:14