Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Feb 1997 10:07:42 +1030 (CST)
From:      Michael Smith <msmith@atrad.adelaide.edu.au>
To:        abelits@phobos.illtel.denver.co.us (Alex Belits)
Cc:        terry@lambert.org, guido@gvr.win.tue.nl, dillon@best.net, gurney_j@resnet.uoregon.edu, top@sonic.cris.net, audit-bin@freebsd.org, FreeBSD-hackers@freebsd.org
Subject:   Re: hmm
Message-ID:  <199702222337.KAA00728@genesis.atrad.adelaide.edu.au>
In-Reply-To: <Pine.LNX.3.95.970222123316.30792B-100000@phobos.illtel.denver.co.us> from Alex Belits at "Feb 22, 97 12:35:09 pm"

next in thread | previous in thread | raw e-mail | index | archive | help

Alex Belits stands accused of saying:
> On Sat, 22 Feb 1997, Terry Lambert wrote:
> 
> > > with p=""  
> > > *p != '\0' && p[strlen(p) - 1] == '[' _still_ will read a byte p[-1].
> > 
> > What?
> > 
> > 	IF p = ""
> > 	THEN *p = '\0'
> > 
> > by definition of ""...
> 
> but p[strlen(p) - 1] will be p[-1]
> Optimization done by compiler may skip it, but depending on that will be
> rather dangerous.

We just had this discussion, and as the erring party in the previous
iteration, I find myself obliged to point out that the C language
specification mandates that arguments to '&&' are evaluated
left-to-right, and that evaluation stops as soon as a conclusive
condition is met.

Thus, if *p is 0, p[-1] will _not_ be referenced.

> Alex

-- 
]] Mike Smith, Software Engineer        msmith@gsoft.com.au             [[
]] Genesis Software                     genesis@gsoft.com.au            [[
]] High-speed data acquisition and      (GSM mobile)     0411-222-496   [[
]] realtime instrument control.         (ph)          +61-8-8267-3493   [[
]] Unix hardware collector.             "Where are your PEZ?" The Tick  [[



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702222337.KAA00728>