String i = i + foo(); not defined in your program, but not undefined.
Compilers try to issue warnings without false positives (every time the compiler warns there is a defect that the programmer should fix) or, at least, with very low false positives. This means that in return they have quite a few false negatives. Consistent with the same philosophy, compilers do not usually warn of unspecified behavior.
To get a warning about your program, you should study static analyzers that are more aggressive with respect to warnings, at the cost of slightly more false positives. Static analyzers can very well decide to warn about unspecified behavior. Some of them even warn of certain behaviors, which, although defined, indicate that the programmer was probably confused.
Pascal cuoq
source share