From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14420 invoked by alias); 14 Jul 2015 09:20:46 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35793 Received: (qmail 22364 invoked from network); 14 Jul 2015 09:20:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f5-f794b6d000001495-b0-55a4d464869e Date: Tue, 14 Jul 2015 10:20:33 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Undefined behaviour warnings with zsh.git and clang Message-id: <20150714102033.0f92c5de@pwslap01u.europe.root.pri> In-reply-to: References: Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: quoted-printable X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMLMWRmVeSWpSXmKPExsVy+t/xa7opV5aEGhy7ZGRxsPkhkwOjx6qD H5gCGKO4bFJSczLLUov07RK4MjbNuspacJ2n4tLJo2wNjG85uxg5OSQETCS+XF7ADmGLSVy4 t56ti5GLQ0hgKaNEz9f1jBDODCaJgzsfQznbGCUOfJnFCtLCIqAqse37D2YQm03AUGLqptmM ILaIgLjE2bXnWboYOTiEBRwk3h5gAwnzCthLHD1yhQXE5hQwk5jy/TxYuZCAqcTKC9/BxvAL 6Etc/fuJCeIie4mZV84wQvQKSvyYfA+sl1lAXWLSvEXMELa2xJN3F1gh5qhL3Li7m30Co9As JC2zkLTMQtKygJF5FaNoamlyQXFSeq6RXnFibnFpXrpecn7uJkZI0H7dwbj0mNUhRgEORiUe 3gmWS0KFWBPLiitzDzFKcDArifBabAQK8aYkVlalFuXHF5XmpBYfYpTmYFES5525632IkEB6 YklqdmpqQWoRTJaJg1OqgfHS7X9/8zgFDpXr/andm5R7+teXv9HJPlL+1++mqj9dxfhr7nyt Pbzl5scWvVz85sFBnfLrz6vOVfGnhWaweUom7nRT/i7IeeT6865Q07oJv13zboY80+8UX+ce x/NESI+jRsBs298q7lBJ34u/Ui6eeu2acLMjcu/8+QaHz/YX3JHRktsiaqPEUpyRaKjFXFSc CABpD232VgIAAA== On Tue, 14 Jul 2015 08:48:17 +0000 =C4=B0smailD=C3=B6nmez wrote: > With git master I started to see: >=20 > clang -c -I. -I../Src -I../Src -I../Src/Zle -I. -DHAVE_CONFIG_H -O2 -fPI= E - > fstack-protector -I/usr/include/ncurses6/ncursesw -I/usr/include/ncurses6= - > o params.o params.c > params.c:1721:18: warning: shifting a negative signed value is undefined = [- > Wshift-negative-value] > v->isarr |=3D SCANPM_ISVAR_AT; > ^~~~~~~~~~~~~~~ > ./zsh.h:1755:32: note: expanded from macro 'SCANPM_ISVAR_AT' > #define SCANPM_ISVAR_AT ((-1)<<15) /* "$foo[@]"-style substitution > ~~~~^ > params.c:1933:36: warning: shifting a negative signed value is undefined = [- > Wshift-negative-value] This hasn't changed, but wherever the warning's started coming from it's valid. I think the following uses the same bit patterns and final value without any undefined behaviour, unless anyone can see otherwise. Alaternatively (-1 & ~0xFFFF) might be neater. pws diff --git a/Src/zsh.h b/Src/zsh.h index 69fef33..a99c900 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1752,9 +1752,10 @@ struct tieddata { * necessarily want to match multiple * elements */ -#define SCANPM_ISVAR_AT ((-1)<<15) /* "$foo[@]"-style substitution - * Only sign bit is significant - */ +/* "$foo[@]"-style substitution + * Only sign bit is significant + */ +#define SCANPM_ISVAR_AT ((int)(((unsigned int)-1)<<15)) =20 /* * Flags for doing matches inside parameter substitutions, i.e.