aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/enum-flags.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/gdb/common/enum-flags.h b/gdb/common/enum-flags.h
index 82568a5..f7ca8d8 100644
--- a/gdb/common/enum-flags.h
+++ b/gdb/common/enum-flags.h
@@ -164,6 +164,12 @@ public:
}
enum_flags operator~ () const
{
+ // We only the underlying type to be unsigned when actually using
+ // operator~ -- if it were not unsigned, undefined behavior could
+ // result. However, asserting this in the class itself would
+ // require too many unnecessary changes to otherwise ok enum
+ // types.
+ gdb_static_assert (std::is_unsigned<underlying_type>::value);
return (enum_type) ~underlying_value ();
}