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 assertion ...



details:   https://anonhg.NetBSD.org/src/rev/5908bf93ca20
branches:  trunk
changeset: 379009:5908bf93ca20
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue May 04 05:32:52 2021 +0000

description:
tests/lint: demonstrate assertion failure "len == size_in_bits(INT)"

Seen on sparc64 in hdtoa.c:341 since sparc64 is one of the platforms
that has 128-bit long double and defines struct ieee_ext.ext_frach:48
based on uint64_t, which is a GCC extension.  Plain C99 only allows
_Bool, signed int and unsigned int as base type for bit-fields.

diffstat:

 tests/usr.bin/xlint/lint1/gcc_bit_field_types.c |  18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diffs (29 lines):

diff -r 6badc9191cc8 -r 5908bf93ca20 tests/usr.bin/xlint/lint1/gcc_bit_field_types.c
--- a/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c   Mon May 03 20:07:57 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c   Tue May 04 05:32:52 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gcc_bit_field_types.c,v 1.3 2021/05/02 22:07:49 rillig Exp $   */
+/*     $NetBSD: gcc_bit_field_types.c,v 1.4 2021/05/04 05:32:52 rillig Exp $   */
 # 3 "gcc_bit_field_types.c"
 
 /*
@@ -19,3 +19,19 @@ struct example {
        unsigned long long unsigned_long_long_flag: 1;
        double double_flag: 1;  /* expect: illegal bit-field type 'double' */
 };
+
+struct large_bit_field {
+       unsigned long long member: 48;
+};
+
+unsigned long long
+promote_large_bit_field(struct large_bit_field lbf)
+{
+       /*
+        * Before tree.c 1.281 from 2021-05-04:
+        * lint: assertion "len == size_in_bits(INT)" failed
+        *     in promote at tree.c:1698
+        */
+       /* TODO: remove the cast since it hides an assertion failure */
+       return (unsigned long long)lbf.member & 0xf;
+}



Home | Main Index | Thread Index | Old Index