[PATCH 02/12] enum: add testcase for UB in oversized shift

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



type_is_ok(), used to calculate the base type of enums,
has a bug related to UB when doing a full width rshift.

Add a testcase for this.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/bug-rshift-ub.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 validation/bug-rshift-ub.c

diff --git a/validation/bug-rshift-ub.c b/validation/bug-rshift-ub.c
new file mode 100644
index 000000000..3a5f3a577
--- /dev/null
+++ b/validation/bug-rshift-ub.c
@@ -0,0 +1,17 @@
+enum a {
+	A = ~0ULL,
+};
+
+static enum a a = A;
+
+/*
+ * check-name: bug-rshift-ub
+ * check-known-to-fail
+ * check-description:
+ *	This test trigger(ed) a bug on x86 caused by a
+ *	full width shift (which is UB), expecting to get
+ *	0 but giving the unshifted value and as result
+ *	the type is invalid:
+ *		warning: incorrect type in initializer (invalid types)
+ *			 expected bad type enum a static [toplevel] a
+ */
-- 
2.18.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux