Subj : Re: returning arguments To : comp.programming.threads From : Sergey P. Derevyago Date : Fri Jul 01 2005 05:38 pm David Butenhof wrote: > > The effect of using an invalid pointer value ... is undefined (On some > > implementations, it causes a system-generated runtime fault). > > I usually take care to point out that the semantics of casting between > integer and pointer types itself is not completely defined by the > standard. The clause you point out is also valid, but generally of less > concern because it applies only if you dereference the "not really a > pointer" value. > Not correct, sorry. The standard clearly stands: "effect of _using_ an invalid pointer value" and copying *is* using. That is even: void f(void*); void g(int i) { f((void*)i); // undefined behavior! } is undefined behavior. It's allowed to assign _to_ pointers containing invalid pointer values, though: void h() { int* pi=new int(1); delete pi; // now pi contains invalid pointer value int* pi2=pi; // undefined behavior! pi=new int(2); // ok, now pi is valid again } > HOWEVER, this stuff is safe on any mainstream C/UNIX class of system > because it's always been presumed to be safe by a vast body of extant > code -- breaking that would be severely limiting no matter how legal it > is. > Agreed. -- With all respect, Sergey. http://ders.angen.net/ mailto : ders at skeptik.net .