Misc fixes for cpp backend.

PR17317.