Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: demonstrate wrong fold...



details:   https://anonhg.NetBSD.org/src/rev/bdf030432d5a
branches:  trunk
changeset: 1023078:bdf030432d5a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 22 20:14:24 2021 +0000

description:
tests/lint: demonstrate wrong folding of 64-bit numbers

diffstat:

 tests/usr.bin/xlint/lint1/expr_fold.c   |  21 ++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/expr_fold.exp |   1 +
 2 files changed, 21 insertions(+), 1 deletions(-)

diffs (40 lines):

diff -r 6f5c6a90b3ca -r bdf030432d5a tests/usr.bin/xlint/lint1/expr_fold.c
--- a/tests/usr.bin/xlint/lint1/expr_fold.c     Sun Aug 22 19:56:15 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/expr_fold.c     Sun Aug 22 20:14:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expr_fold.c,v 1.2 2021/08/19 20:48:47 rillig Exp $     */
+/*     $NetBSD: expr_fold.c,v 1.3 2021/08/22 20:14:24 rillig Exp $     */
 # 3 "expr_fold.c"
 
 /*
@@ -285,3 +285,22 @@
        take_bool(1 | 3);
        take_bool(3 | 1);
 }
+
+/*
+ * The following expression originated in vndcompress.c 1.29 from 2017-07-29,
+ * where line 310 contained a seemingly harmless compile-time assertion that
+ * expanded to a real monster expression.
+ *
+ * __CTASSERT(MUL_OK(uint64_t, MAX_N_BLOCKS, MAX_BLOCKSIZE));
+ */
+struct ctassert5_struct {
+       unsigned int member:
+           /*CONSTCOND*/
+           0xfffffffeU
+           <=
+               ((1ULL << 63) + 1 < 1 ? ~(1ULL << 63) : ~0ULL) / 0xfffffe00U
+               ? 1
+               /* FIXME: the above '(1ULL << 63) + 1' is wrong */
+               /* expect+1: error: illegal bit-field size: 255 [36] */
+               : -1;
+};
diff -r 6f5c6a90b3ca -r bdf030432d5a tests/usr.bin/xlint/lint1/expr_fold.exp
--- a/tests/usr.bin/xlint/lint1/expr_fold.exp   Sun Aug 22 19:56:15 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/expr_fold.exp   Sun Aug 22 20:14:24 2021 +0000
@@ -51,3 +51,4 @@
 expr_fold.c(207): warning: integer overflow detected, op << [141]
 expr_fold.c(211): warning: shift amount 104 is greater than bit-size 32 of 'unsigned int' [122]
 expr_fold.c(223): warning: shift amount 104 is greater than bit-size 32 of 'int' [122]
+expr_fold.c(305): error: illegal bit-field size: 255 [36]



Home | Main Index | Thread Index | Old Index