path: root/src/corelib/global/qflags.h
diff options
authorMarc Mutz <>2012-09-26 16:16:14 +0200
committerThe Qt Project <>2012-09-27 02:25:15 +0200
commita19fd0f9265bed96197a6823887c6f03fc23112d (patch)
tree28d010e431e4b9381656a426a3734761c58a35f9 /src/corelib/global/qflags.h
parentce1f994e9bcdea963a81a4bf562a8317cf6e0089 (diff)
QFlags: fail for 64-bit enums
An int is not enough to hold all values of a 64-bit enum, so don't allow to compile QFlags for such enums. Change-Id: Ia291c4a5e2160dfd6d5a35e61a7f71ab571b9d9a Reviewed-by: Thiago Macieira <>
Diffstat (limited to 'src/corelib/global/qflags.h')
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index 7cf06d7e88..faacf7321c 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -77,6 +77,9 @@ Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {}
template<typename Enum>
class QFlags
+ Q_STATIC_ASSERT_X((sizeof(Enum) <= sizeof(int)),
+ "QFlags uses an int as storage, so an enum with underlying "
+ "long long would overflow. Qt 5.1 will have support for 64bit enums.");
struct Private;
typedef int (Private::*Zero);
int i;