Itseez/opencv — pull request #1392 by SpecLad (2013-09-03 15:50:23+00:00)
Title: Fix a bug in FLANN resulting in uninitialized accesses

This might fix this intermittent error: http://build.opencv.org/builders/precommit_ubuntu_nosse/builds/2285.

The first commit is cherrypicked from mariusmuja/flann@b615f26.

Since it took me a while to understand what the bug is, and the original commit message is no help, here's a brief explanation. In the const version of `any::cast`, if `policy` is a `small_any_policy`, its `get_value` returns its input argument. So `r` becomes a pointer to `obj`, and the return value is a reference to a local variable, which is invalidated when the function exits.