From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 131058 invoked by alias); 23 Nov 2017 11:09:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 131046 invoked by uid 89); 23 Nov 2017 11:09:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=BAYES_00,KB_WAM_FROM_NAME_SINGLEWORD,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=Hx-languages-length:1023 X-HELO: mx2.suse.de From: Andreas Schwab To: Florian Weimer Cc: Siddhesh Poyarekar , GNU C Library , Adhemerval Zanella Subject: Re: [PATCH] support: Add TEST_COMPARE macro References: <8d63a2dc-f9e9-acaa-5ac5-ac5c4fbd6c9f@redhat.com> <8c399cde-3093-0195-a89a-ca230540cffb@gotplt.org> <8339a519-935a-019c-4a8f-798e37f6f346@redhat.com> X-Yow: This is a NO-FRILLS flight -- hold th' CANADIAN BACON!! Date: Thu, 23 Nov 2017 11:09:00 -0000 In-Reply-To: <8339a519-935a-019c-4a8f-798e37f6f346@redhat.com> (Florian Weimer's message of "Thu, 23 Nov 2017 11:54:05 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2017-11/txt/msg00827.txt.bz2 On Nov 23 2017, Florian Weimer wrote: > +/* Compare the two integers LEFT and RIGHT and report failure if they > + are different. */ > +#define TEST_COMPARE(left, right) \ > + ({ \ > + __typeof__ (left) __left_value = (left); \ > + __typeof__ (right) __right_value = (right); \ > + /* Prevent accidental use with larger-than-long long types. */ \ > + _Static_assert (sizeof (__left_value) <= sizeof (long long), \ > + "left value fits into long long"); \ > + _Static_assert (sizeof (__right_value) <= sizeof (long long), \ > + "right value fits into long long"); \ > + /* Compare the value and the sign, to avoid false equality. */ \ > + /* (A signed value could be converted to an unsigned type.) */ \ Why do you need that? Any signed value converted to unsigned is still unique. Andreas. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."