🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2179

Re: Behaviour of mem functions when n=0 ?

#2179
From: Larry Jones
Date: Tue, 05 Mar 1996 03:23
26 lines
1689 bytes
In article <4hdqn5$8qn@solutions.solon.com>, fred@genesis.demon.co.uk
(Lawrence Kirby) writes about memcmp et al. with n==0:
> Probably. However the result is defined by some rather unfortunate wording in
> the standard:

The intent of the standard has been clarified by a Technical Corrigendum
which adds the following text to the introductory matter in 7.11.1
String Function Conventions:

	Where an argument declared as |size_t n| specifies the length of
	the array for a function, |n| can have the value zero on a call
	to that function.  Unless explicitly stated otherwise in the
	description of a particular function in this subclause, pointer
	arguments on such a call must still have valid values, as
	described in subclause 7.1.7.  On such a call, a function that
	locates a character finds no occurrence, a function that
	compares two character sequences returns zero, and a function
	that copies characters copies zero characters.

Note that this applies to the strn* functions as well as the mem*
functions.
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
larry.jones@sdrc.com
Well of course the zipper's going to get stuck if everyone
stands around WATCHING me! -- Calvin
Technical Details
Message-ID: <4hgc3d$97a@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4hdqn5$8qn@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: larry.jones@sdrc.com (Larry Jones)
Newsgroups: comp.lang.c.moderated,comp.std.c
Subject: Re: Behaviour of mem functions when n=0 ?
Date: 4 Mar 1996 21:23:25 -0600
Organization: SDRC Engineering Services
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4hgc3d$97a@solutions.solon.com>
References: <4hdqn5$8qn@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com