RE: Null src pointer in memcpy?

2008-04-11 Thread Eric Lemings
 
I was just asking because I observed such a call in _rw_bufcat().
It happens when the printf-like functions in tests/src/printf.cpp
are creating a new buffer for formatting operations.

Brad.

 -Original Message-
 From: Martin Sebor [mailto:[EMAIL PROTECTED] On Behalf Of Martin Sebor
 Sent: Thursday, April 10, 2008 7:40 PM
 To: dev@stdcxx.apache.org
 Subject: Re: Null src pointer in memcpy?
 
 This is explicitly required in 7.1.4 of C99:
 
7.1.4 Use of library functions
 
-1- Each of the following statements applies unless 
 explicitly stated
otherwise in the detailed descriptions that follow: 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. ...
 
 Here's an answer to the same question on comp.lang.c.moderated:
http://tinyurl.com/6eqo3n
 
 Martin Sebor wrote:
  Eric Lemings wrote:
   
  Is it safe to pass a null pointer as the 2nd argument to 
 memcpy()?  Or
  undefined?
  
  Assuming the third argument is 0. Strictly speaking I believe it's
  undefined because memcpy(s1, s2, n) is specified to copy n bytes
  from the object pointed to by s2 into the object pointed to by s1
  and a null pointer doesn't point to an object. An object is defined
  as a region of storage in the execution environment, the contents
  of which can represent values.
  
  AFAIK, most implementations allow null pointers for no-op calls to
  memcpy() but gcc issues a warning when it detects at compile time
  that a null pointer is passed as the first or second argument to
  memcpy().
  
  Martin
  
 
 


_RWSTD_NO_BOOL vs _RWSTD_NO_NATIVE_BOOL

2008-04-11 Thread Farid Zaripov
  In library headers somewhere used _RWSTD_NO_BOOL and somewhere - 
_RWSTD_NO_NATIVE_BOOL.
The _RWSTD_NO_BOOL.is determined at configure step, but _RWSTD_NO_NATIVE_BOOL - 
not. At the same time
_RWSTD_NO_NATIVE_BOOL mentioned in readme file, while _RWSTD_NO_BOOL - doesn't.
What the difference between these macros?
 
Shouldn't be _RWSTD_NO_NATIVE_BOOL. replaced with _RWSTD_NO_BOOL.?
 
Farid.
 


Re: _RWSTD_NO_BOOL vs _RWSTD_NO_NATIVE_BOOL

2008-04-11 Thread Martin Sebor

Farid Zaripov wrote:

  In library headers somewhere used _RWSTD_NO_BOOL and somewhere - 
_RWSTD_NO_NATIVE_BOOL.
The _RWSTD_NO_BOOL.is determined at configure step, but _RWSTD_NO_NATIVE_BOOL - 
not. At the same time
_RWSTD_NO_NATIVE_BOOL mentioned in readme file, while _RWSTD_NO_BOOL - doesn't.
What the difference between these macros?
 
Shouldn't be _RWSTD_NO_NATIVE_BOOL. replaced with _RWSTD_NO_BOOL.?


The _NO_NATIVE_XXX macros (_RWSTD_NO_NATIVE_BOOL and
_RWSTD_NO_NATIVE_WCHAR_T) are #defined when the respective type isn't
a distinct type. The others are #defined when the type isn't provided
at all, not even as a typedef. We probably could drop the second kind
because we don't depend on any typedefs like that. It might even make
sense to get rid of both kinds of macros and assume that both bool
and wchar_t are always provided as distinct types. We talked about
doing a review of all these workarounds in the future (sometime after
4.2) and cleaning things up -- see this post:
  http://stdcxx.markmail.org/message/zuawhacu2cihto4y
It might make sense to add these to the list.

Martin