From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 13 Jan 2016 22:54:46 +0000 From: Al Viro To: Chen Gang Cc: dhowells@redhat.com, akpm@linux-foundation.org, nicolas.iooss_linux@m4x.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] fs: dcache: Use bool return value instead of int Message-ID: <20160113225446.GU17997@ZenIV.linux.org.uk> References: <1452547845-12039-1-git-send-email-chengang@emindsoft.com.cn> <20160111225104.GO17997@ZenIV.linux.org.uk> <5695733C.1010201@emindsoft.com.cn> <20160112222105.GT17997@ZenIV.linux.org.uk> <5696D239.2000605@emindsoft.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5696D239.2000605@emindsoft.com.cn> Sender: linux-kernel-owner@vger.kernel.org List-ID: On Thu, Jan 14, 2016 at 06:39:53AM +0800, Chen Gang wrote: > > As for the inlines... frankly, if gcc generates a different code from having > > replaced int with bool in those, it's time to do something very nasty to > > gcc developers. > > > > Could you provide the related proof? static inline _Bool f(.....) { return ; } ... if (f(.....)) should generate the code identical to if ((_Bool)) which, in turn, should generate the code identical to if ( != 0) and if () Neither explicit nor implicit conversion to _Bool (the former by the explicit cast, the latter - by declaring f() to return _Bool) matters at all when the damn thing is inlined in a condition context. Conversion to _Bool is equivalent to comparison with 0, and so is the use in condition of if() and friends. For something not inlined you might get different code generated due to a difference in calling sequences of _Bool(...) and int(...); for inlined case having one of those variants produce a better code means that compiler has managed to miss some trivial optimization in all other variants. And I'm yet to see any proof that gcc *does* fuck up in that fashion. It might - dumb bugs happen to everyone, but I would not assume that they'd managed to do something that bogys without experimental evidence.