From: David Laight <David.Laight@ACULAB.COM>
To: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>,
"'Andy Shevchenko'" <andriy.shevchenko@linux.intel.com>,
'Andrew Morton' <akpm@linux-foundation.org>,
"'Matthew Wilcox (Oracle)'" <willy@infradead.org>,
'Christoph Hellwig' <hch@infradead.org>,
"'Jason A. Donenfeld'" <Jason@zx2c4.com>
Cc: 'Nathan Chancellor' <nathan@kernel.org>,
"llvm@lists.linux.dev" <llvm@lists.linux.dev>
Subject: RE: [PATCH next v2 5/5] minmax: Relax check to allow comparison between int and small unsigned constants.
Date: Mon, 31 Jul 2023 13:26:54 +0000 [thread overview]
Message-ID: <9c14002108ff49e1a54819133fe9e2a3@AcuMS.aculab.com> (raw)
In-Reply-To: <b4ce9dad748e489f9314a2dc95615033@AcuMS.aculab.com>
By the time I've done:
#define __is_noneg_int(x) \
__builtin_choose_expr(!__is_constexpr(x), false, \
((x) >= (typeof(x))0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))
#define __is_signed(x) \
__builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
is_signed_type(typeof(x)), 0)
#define __types_ok(x, y) \
(__is_signed(x) == __is_signed(y) || \
__is_signed((x) + 0) == __is_signed((y) + 0) || \
__is_noneg_int(x) || __is_noneg_int(y))
the error message for
> static_assert(__types_ok(x, y), \
> #op "(" #x ", " #y ") signedness error, fix types or consider " #op "_unsigned() before " #op "_t()"); \
generated by clang 8.0.0 and later is similar to (see https://godbolt.org/z/jq613Gnsa):
<source>:49:12: error: static assertion failed due to requirement '__builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((int)(-1)) < (int)1)) * 0L)) : (int *)8))), (((int)(-1)) < (int)1), 0) == __builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((unsigned int)(-1)) < (unsigned int)1)) * 0L)) : (int *)8))), (((unsigned int)(-1)) < (unsigned int)1), 0) || __builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((int)(-1)) < (int)1)) * 0L)) : (int *)8))), (((int)(-1)) < (int)1), 0) == __builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((unsigned int)(-1)) < (unsigned int)1)) * 0L)) : (int *)8))), (((unsigned int)(-1)) < (unsigned int)1), 0) || (__builtin_choose_expr(!(sizeof(int) == sizeof (*(8 ? ((void *)((long)(a) * 0L)) : (int *)8))), 0, __builtin_choose_expr(__builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((int)(-1)) < (int)1)) * 0L)) : (int *)8))), (((int)(-1)) < (int)1), 0), a, 0) >= 0 && (a) <= (int)(long)2147483647)) || (__builtin_choose_expr(!(sizeof(int) == sizeof (*(8 ? ((void *)((long)(2147483648U - 0) * 0L)) : (int *)8))), 0, __builtin_choose_expr(__builtin_choose_expr((sizeof(int) == sizeof (*(8 ? ((void *)((long)((((unsigned int)(-1)) < (unsigned int)1)) * 0L)) : (int *)8))), (((unsigned int)(-1)) < (unsigned int)1), 0), 2147483648U - 0, 0) >= 0 && (2147483648U - 0) <= (unsigned int)(long)2147483647))': min(a, 0x80000000u - 0) signedness error, fix types or consider min_unsigned() before min_t()
Repeating the expression seems somewhat sub-optimal!
Surely it shouldn't be outputting the expansion of the
input when an error message is supplied?
Is there any (sane) way to stop it being that verbose?
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2023-07-31 13:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-28 14:49 [PATCH next v2 0/5] minmax: Relax type checks in min() and max() David Laight
2023-07-28 14:50 ` [PATCH next v2 1/5] minmax: Add min_unsigned(a, b) and max_unsigned(a, b) David Laight
2023-07-28 14:51 ` [PATCH next v2 2/5] minmax: Allow min()/max()/clamp() if the arguments have the same signedness David Laight
2023-07-29 2:00 ` kernel test robot
2023-07-30 14:55 ` David Laight
2023-07-30 17:05 ` Nathan Chancellor
2023-07-30 17:33 ` David Laight
2023-07-31 21:43 ` kernel test robot
2023-08-01 8:45 ` David Laight
2023-07-28 14:52 ` [PATCH next v2 3/5] minmax: Fix indentation of __cmp_once() and __clamp_once() David Laight
2023-07-28 14:52 ` [PATCH next v2 4/5] minmax: Allow comparisons of 'int' against 'unsigned char/short' David Laight
2023-07-28 14:53 ` [PATCH next v2 5/5] minmax: Relax check to allow comparison between int and small unsigned constants David Laight
2023-07-28 21:43 ` kernel test robot
2023-07-30 16:55 ` David Laight
2023-07-31 13:26 ` David Laight [this message]
2023-08-01 16:02 ` Nick Desaulniers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9c14002108ff49e1a54819133fe9e2a3@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=Jason@zx2c4.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®