From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8161 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: Left-shift of negative number Date: Sat, 18 Jul 2015 01:40:02 +0200 Message-ID: <20150717234002.GA8664@port70.net> References: <1437164614.30461.5.camel@inria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1437176419 3818 80.91.229.3 (17 Jul 2015 23:40:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 17 Jul 2015 23:40:19 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8174-gllmg-musl=m.gmane.org@lists.openwall.com Sat Jul 18 01:40:18 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZGFEm-0001Pd-7H for gllmg-musl@m.gmane.org; Sat, 18 Jul 2015 01:40:16 +0200 Original-Received: (qmail 19741 invoked by uid 550); 17 Jul 2015 23:40:14 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 19718 invoked from network); 17 Jul 2015 23:40:14 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <1437164614.30461.5.camel@inria.fr> User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:8161 Archived-At: * Jens Gustedt [2015-07-17 22:23:34 +0200]: > Am Freitag, den 17.07.2015, 19:55 +0000 schrieb Pascal Cuoq: > > I know that this is not well-known, so perhaps I should explain: ever since > > the late 1990s, C compilers have been taking advantage of undefined behavior > > in the C standard to introduce new optimizations. > > No it is actually the other way around. The C standard voluntarily > leaves certain behavior undefined to have leeway for compiler and > library implementors to do what they (think they) have to do. So there > is a clear distinction what UB means for "user" code and for the > implementation. > i agree.. > musl (and other C libraries I suppose) heavily rely on specific > properties of compilers, that is basically all what the writing of a C > library for a specific platform is about. ..but musl does not want to depend on special compiler properties, so i disagree with this. a libc should not make unnecessary assumptions about other components of the implementation. (there are cases where the assumptions are necessary and reasonable, but negative shift is always possible to avoid). and it is a good thing to know our assumptions beyond the guarantees of the standard (eg. musl relies on that int is 2's complement and at least 32bit) so bug reports about "ub" or "idb" is ok.