delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/09/02/13:24:24

Date: Tue, 2 Sep 2003 13:24:01 -0400
Message-Id: <200309021724.h82HO1ah017641@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp-workers AT delorie DOT com
CC: Melvin AT HME DOT Ltd DOT uk, djgpp-workers AT delorie DOT com
In-reply-to: <7458-Tue02Sep2003201254+0300-eliz@elta.co.il>
Subject: Re: Non-compliant strxfrm
References: <F1A9C8D7A58D1B45A9C16FE7E3DA83D7021890 AT server DOT HME DOT hme DOT ltd DOT uk> <7458-Tue02Sep2003201254+0300-eliz AT elta DOT co DOT il>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Thanks, but I think this needs some further work, since this fragment:
> 
>      if (--n)
>        *dst++ = c;
> 
> seems to dereference dst even if n is zero.  The standard forbids
> that, see our prior discussions in this thread.

No, it can't.  That case is already detected in the preceeding if:

    if (n < 2)
    {
      while (*src++ != 0)
        r++;
      break;
    }
    if (--n)
      *dst++ = c;

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019