From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52982 invoked by alias); 17 Apr 2017 14:44: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 52969 invoked by uid 89); 17 Apr 2017 14:44:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy= X-HELO: albireo.enyo.de From: Florian Weimer To: Dennis =?iso-8859-1?Q?W=F6lfing?= Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v2] Add reallocarray function. References: <20170410150053.10208-1-denniswoelfing@gmx.de> <20170417140148.23212-1-denniswoelfing@gmx.de> <874lxnf6jw.fsf@mid.deneb.enyo.de> Date: Mon, 17 Apr 2017 14:44:00 -0000 In-Reply-To: ("Dennis \=\?iso-8859-1\?Q\?W\=F6lfing\=22's\?\= message of "Mon, 17 Apr 2017 16:40:36 +0200") Message-ID: <87ziffdrfg.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2017-04/txt/msg00290.txt.bz2 * Dennis W=F6lfing: > On 17.04.2017 16:32, Florian Weimer wrote: >> * Dennis W=F6lfing: >>=20 >>> +static inline bool >>> +check_mul_overflow (size_t l, size_t r, INTERNAL_SIZE_T *result) >>> +{ >>> +#if __GNUC__ >=3D 5 >>> + return __builtin_mul_overflow (l, r, result); >>=20 >> This is not correct for size_t !=3D INTERNAL_SIZE_T. Either change the >> type of result to size_t * (so that the code fails to compile if the >> types differ, something which we have not done for a long time), or >> add another check against (INTERNAL_SIZE_T) -1. > > Are you sure that this is not correct? The GCC manual says about the > overflow builtins: Sorry, you are right. I actually tested this, but misread the generated assembly.