[PATCH 1/3] add test for enum sign extension

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

 



In a declaration like:
	enum {
	        a = 0x80000000,
	        b = -1,
	}
the underlying type should be long and b's value should be
0xffffffffffffffff (on a 64-bit machine) but is 0xffffffff.

Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/enum-sign-extend.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 validation/enum-sign-extend.c

diff --git a/validation/enum-sign-extend.c b/validation/enum-sign-extend.c
new file mode 100644
index 000000000..7f17debac
--- /dev/null
+++ b/validation/enum-sign-extend.c
@@ -0,0 +1,12 @@
+enum num {
+	a = 0x80000000,
+	b = -1,
+};
+
+_Static_assert([typeof(b)] == [long], "type");
+_Static_assert(b == -1L,              "value");
+
+/*
+ * check-name: enum-sign-extend
+ * check-known-to-fail
+ */
-- 
2.23.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