[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Change in strncmp, at least on PowerPC
From: |
Andreas Schwab |
Subject: |
Re: Change in strncmp, at least on PowerPC |
Date: |
Fri, 23 Jan 2004 11:16:55 +0100 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux) |
Bob Schmertz <address@hidden> writes:
> The problem is this: if strncmp is called with a null pointer for at
> least one of the strings, and n is supplied as 0, it segfaults.
Don't do that then.
7.21.1 String function conventions
2. 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 shall still have valid values, as described in 7.1.4.
7.1.4 Use of library functions
1. ... If an argument to a function has an invalid value (such as a value
outside the domain of the function, or a pointer outside the address
space of the program, or a null pointer, or a pointer to
non-modifiable storage when the corresponding parameter is not
const-qualified) or a type (after promotion) not expected by a
function with variable number of arguments, the behavior is undefined.
> This difference has broken zsh on the PPC platform.
zsh is broken.
Andreas.
--
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."