bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] invalid archive provokes segfault


From: Helmut Waitzmann
Subject: Re: [Bug-tar] invalid archive provokes segfault
Date: Thu, 31 Mar 2005 15:15:58 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Jim Meyering <address@hidden> writes:

>BTW, using `*p' and `p' as arguments to strtoul is odd.
>Doesn't that rely on undefined behavior?  Sort of like
>using memcpy with overlapping regions?

I don't think so.  In order to call strtoul (*p, p, 10),
the run-time environment evaluates the values *p, p, and 10 in an
unspecified order.

However, this evaluation has completed before strtoul gets called:  All
parameters in the programming language C are call by value parameters.
(Even array parameters are call by value parameters:  The address of the
first element of the array is supplied as a pointer value.  In no
circumstances there are lvalue parameters.)

So,

   strtoul(*p, p, 10);

is equivalent to

   { char * tmp = *p;
     strtoul(tmp, p, 10));
   }

with respect to the evaluation of the parameters.  Or do I miss
something?  Maybe, I'm missunderstanding you?
-- 
Wenn Sie mir E-Mail schreiben, stellen |  When writing me e-mail, please
Sie bitte vor meine E-Mail-Adresse     |  precede my e-mail address with
meinen Vor- und Nachnamen, etwa so:    |  my full name, like
Helmut Waitzmann <address@hidden>, (Helmut Waitzmann) address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]