From owner-freebsd-hackers Fri Aug 10 8:28:10 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from ussenterprise.ufp.org (ussenterprise.ufp.org [208.185.30.210]) by hub.freebsd.org (Postfix) with ESMTP id C1B9237B405 for ; Fri, 10 Aug 2001 08:28:01 -0700 (PDT) (envelope-from bicknell@ussenterprise.ufp.org) Received: (from bicknell@localhost) by ussenterprise.ufp.org (8.11.1/8.11.1) id f7AFS1R22251 for hackers@FreeBSD.ORG; Fri, 10 Aug 2001 11:28:01 -0400 (EDT) (envelope-from bicknell) Date: Fri, 10 Aug 2001 11:28:01 -0400 From: Leo Bicknell To: "hackers@FreeBSD.ORG" Subject: Re: the =+ operator Message-ID: <20010810112801.A21795@ussenterprise.ufp.org> Mail-Followup-To: Leo Bicknell , "hackers@FreeBSD.ORG" References: <3B73F0BC.548D40B3@home.com> <200108101446.HAA99867@safety.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200108101446.HAA99867@safety.net>; from les@safety.net on Fri, Aug 10, 2001 at 07:46:16AM -0700 Organization: United Federation of Planets Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Ok, I had to go try this out for my own: % cat test.c int main(void) { int a, b; a = 1; printf("a = %d\n", a); a += 1; printf("a = %d\n", a); a =+ 1; printf("a = %d\n", a); a = +1; printf("a = %d\n", a); b = 1; a =+ b; printf("a = %d\n", a); a =- b; printf("a = %d\n", a); } % cc -Wall test.c test.c: In function `main': test.c:7: warning: implicit declaration of function `printf' test.c:17: warning: control reaches end of non-void function % ./a.out a = 1 a = 2 a = 1 a = 1 a = 1 a = -1 I don't know how hard this would be to do in the compiler, but perhaps there should be a warning available for "a =+ b", but not for "a = +b". Maybe that would be better done in lint? I have to think 99% of the the times this shows up in a program it's a bug/mistake. Check out the reference below. In particular, the indent source is interesting, as is bc. % find . -name "*.[ch]" -print | xargs fgrep "=+" ./contrib/bc/bc/util.c: printf ("Old assignment operatiors are valid. (=-, =+, ...)\n"); ./contrib/cvs/src/wrapper.c: for(temp=++line;*line && (*line!='\'' || line[-1]=='\\');++line) ./contrib/libpam/libpam/pam_misc.c: for (end=++from; *end && *end != ']'; ++end) { ./contrib/nvi/vi/vs_msg.c:#define DIVIDESTR "+=+=+=+=+=+=+=+" ./contrib/tcp_wrappers/percent_x.c: static char ok_chars[] = "1234567890!@%-_=+:,./\ ./lib/libc_r/uthread/uthread_kern.c: _thread_run->last_inactive =+ ./lib/libc_r/uthread/uthread_kern.c: _thread_run->last_inactive =+ UINT_MAX + 1; ./lib/msun/src/e_asin.c: /* asin(1)=+-pi/2 with inexact */ ./lib/msun/src/e_asinf.c: /* asin(1)=+-pi/2 with inexact */ ./lib/msun/src/e_atan2.c: case 1: return y; /* atan(+-0,+anything)=+-0 */ ./lib/msun/src/e_atan2f.c: case 1: return y; /* atan(+-0,+anything)=+-0 */ ./lib/msun/src/e_rem_pio2.c: if(ix<0x4002d97c) { /* |x| < 3pi/4, special case with n=+-1 */ ./lib/msun/src/e_rem_pio2f.c: if(ix<0x4016cbe4) { /* |x| < 3pi/4, special case with n=+-1 */ ./lib/msun/src/e_sqrt.c: return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf ./lib/msun/src/e_sqrtf.c: return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf ./lib/msun/src/s_erf.c: return (double)(1-i)+one/x; /* erf(+-inf)=+-1 */ ./lib/msun/src/s_erff.c: return (float)(1-i)+one/x; /* erf(+-inf)=+-1 */ ./lib/msun/src/s_log1p.c: if(x==-1.0) return -two54/zero; /* log1p(-1)=+inf */ ./lib/msun/src/s_log1pf.c: if(x==(float)-1.0) return -two25/zero; /* log1p(-1)=+inf */ ./lib/msun/src/s_tanh.c: if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */ ./lib/msun/src/s_tanhf.c: if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */ ./release/picobsd/tinyware/oinit/oinit.c: printf("\n\n+=========================================================+\n"); ./release/picobsd/tinyware/oinit/oinit.c: printf("+=========================================================+\n\n"); ./usr.bin/indent/lexi.c: *e_token++ = '='; /* Flip =+ to += */ ./usr.bin/indent/lexi.c: *e_token++ = '='; /* Flip =+ to += */ ./usr.sbin/pcvt/vttest/main.c:ESC 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ `~ BS -- Leo Bicknell - bicknell@ufp.org Systems Engineer - Internetworking Engineer - CCIE 3440 Read TMBG List - tmbg-list-request@tmbg.org, www.tmbg.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message