avoid relying on undefined behaviour
in C++ references may be assumed to be non-null. thanks to @atgeirr for pointing this out.
(note: this PR also fixes a harmless sign comparison warning in the non-linear solver.)
The isInitialized() solution is a step forward, will merge when green.
About the sign fix: had not seen this particular way of handling it before, but it's good enough... (Have seen `for (auto i = 0*dx.size(); ...)` which is a close relative. Not pretty but works well.)
I don't really care about how the sign is fixed either. the "correct" thing to do is probably `decltype(dx.size()) i = 0` but IMO that is even uglier (and I'm even more unsure whether it works if `size()` happens to return a `const` number.)
Is green, merging.
> I don't really care about how the sign is fixed either. the "correct" thing to do is probably decltype(dx.size()) i = 0 but IMO that is even uglier (and I'm even more unsure whether it works if size() happens to return a const number.)
I totally agree that there is a tradeoff between correct and unreadable, and decltype is a trick best left for truly generic code.