summaryrefslogtreecommitdiff
path: root/glib
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2020-12-08 15:04:34 +0100
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2020-12-08 15:04:34 +0100
commit12b5837128ab022a26f324e3476ccc7ede51e9b5 (patch)
tree01804f3cd6a3e3afd1851e7ced9d100a2ca90251 /glib
parent8d77eea3d1ac65a5766e98bc3d116d60dee1ace0 (diff)
downloadglibmm-12b5837128ab022a26f324e3476ccc7ede51e9b5.tar.gz
Glib::Binding: Avoid warning from gcc-10
g++-10 with optimization level -O1 or higher warns about possible use of an uninitialized variable when tests/glibmm_binding/main.cc is compiled. I don't understand why. There is no warning if the private method Glib::Binding::TransformProp:: operator()() is compiled without optimization. Add an attribute that turns off optimization for this method when it's compiled with with gcc-10 or higher. gcc-9 does not warn. gcc-10 does not warn in glibmm-2.4, where std::optional is not used.
Diffstat (limited to 'glib')
-rw-r--r--glib/src/binding.hg9
1 files changed, 9 insertions, 0 deletions
diff --git a/glib/src/binding.hg b/glib/src/binding.hg
index 52bbbdb6..73451ba4 100644
--- a/glib/src/binding.hg
+++ b/glib/src/binding.hg
@@ -417,6 +417,15 @@ private:
public:
explicit TransformProp(const SlotTypedTransform<T_from, T_to>& slot) : typed_transform(slot) {}
+ // g++-10 with optimization level -O1 or higher warns about possible use of
+ // an uninitialized variable when tests/glibmm_binding/main.cc is compiled.
+ // I don't understand why. Don't optimize this function. /Kjell 2020-12-08
+ // sigc++-3.0/sigc++/functors/slot.h:226:21: warning: ‘<anonymous>’ may be
+ // used uninitialized in this function [-Wmaybe-uninitialized]
+ // 226 | return T_return();
+#if __GNUC__ >= 10
+ __attribute__ ((optimize(0)))
+#endif
bool operator()(const GValue* from_value, GValue* to_value)
{
Glib::Value<T_from> from_glib_value;