diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-05-01 23:20:51 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-10-05 03:29:19 +0200 |
commit | a4d38cf8543f93d2456e19fc8b603d5843bf054a (patch) | |
tree | 7bc1283e8fa0ed39d6db121ffc1b1e6632bf1491 | |
parent | cdc6e0ce1b6dfe043cd436bd6ac45cbd0fec22c0 (diff) | |
download | sparse-a4d38cf8543f93d2456e19fc8b603d5843bf054a.tar.gz |
enum: add testcase for UB in oversized shift
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@gmail.com>
-rw-r--r-- | validation/bug-rshift-ub.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/validation/bug-rshift-ub.c b/validation/bug-rshift-ub.c new file mode 100644 index 00000000..3a5f3a57 --- /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 + */ |