diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-03-08 22:10:33 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-03-10 17:44:13 +0000 |
| commit | 4b7fab6e3dbb7cae32a2e0b66f1b6ca275367126 (patch) | |
| tree | 9382e45598856321b418eeff1caca390778d6c3d /src/lib | |
| parent | a1fc8268bb7ae1e2eb16b22e79f2ac752362594d (diff) | |
Fix uninitialised variables when failing to raw_convert to POD types.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/raw_convert.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/raw_convert.h b/src/lib/raw_convert.h index 96bd7f633..6e55d49cf 100644 --- a/src/lib/raw_convert.h +++ b/src/lib/raw_convert.h @@ -34,7 +34,12 @@ raw_convert (Q v, int precision = 16) s.imbue (std::locale::classic ()); s << std::setprecision (precision); s << v; - P r; + /* If the s >> r below fails to convert anything, we want r to + be left as a defined value. This construct (I believe) achieves + this by setting r to the default value of type P, even if P + is a POD type. + */ + P r = P (); s >> r; return r; } |
