G
Guest
char *p;
in some place i write...
p=0; *p=0;
do you think it is not good?
dunno. what effect were you hoping for? If there's any sort of memory management it'll likely crash.
char *p;
in some place i write...
p=0; *p=0;
do you think it is not good?
We're talking about libraries.(e-mail address removed)-berlin.de (Stefan Ram) writes:
You snipped too much context. If a piece of code isn't
able to deal with an allocation failure, it doesn't matter
where the allocation falure came from. If a piece of
code is able to deal with allocation failure in some way,
that applies equally to allocation failures for malloc()
and VLAs, assuming of course that VLA allocation failure
can be detected, which I pointed out upthread that it
can in a conforming implementation, if the implementation
so desires. The ability or non-ability of some piece of
code to respond sensibly to allocation failure has no
bearing on the point I was making.
Malcolm McLean said:Tim Rentsch:We're talking about libraries.(e-mail address removed)-berlin.de (Stefan Ram) writes:
You snipped too much context. If a piece of code isn't
able to deal with an allocation failure, it doesn't matter
where the allocation falure came from. If a piece of
code is able to deal with allocation failure in some way,
that applies equally to allocation failures for malloc()
and VLAs, assuming of course that VLA allocation failure
can be detected, which I pointed out upthread that it
can in a conforming implementation, if the implementation
so desires. The ability or non-ability of some piece of
code to respond sensibly to allocation failure has no
bearing on the point I was making.
I want to find the convex hull of a set of points. The algorithm I'm
using needs a temporary buffer. [snip example]
with a vla it's a bit more difficult to provide a corresponding solution.
Weland said:You owe me a new keyboard, I just spilled coffee all over mine when I
burst
into laughter.
Platform specific code can deal with platform-specific stack overflow signals sensibly. Portable code can't. That doesn't mean that portable code might not be able to pass up an out of memory condition, if it can detect it. Caller might not be able to do anything sensible if that happens.Malcolm McLean said:Tim Rentsch:We're talking about libraries.(e-mail address removed)-berlin.de (Stefan Ram) writes:
You snipped too much context. If a piece of code isn't
able to deal with an allocation failure, it doesn't matter
where the allocation falure came from. If a piece of
code is able to deal with allocation failure in some way,
that applies equally to allocation failures for malloc()
and VLAs, assuming of course that VLA allocation failure
can be detected, which I pointed out upthread that it
can in a conforming implementation, if the implementation
so desires. The ability or non-ability of some piece of
code to respond sensibly to allocation failure has no
bearing on the point I was making.
I want to find the convex hull of a set of points. The algorithm I'm
using needs a temporary buffer. [snip example]
with a vla it's a bit more difficult to provide a corresponding solution.
You're making basically the same point that you made upthread, to
which I already responded that it's beside the point I was making.
Did you not understand the point I was making? Do you not
understand what it means for something to be beside the point? Do
you think that repeating yourself is going to magically change
whether what you have to say is relevant? The statement above
(the last one in the quoted excerpt) is true but also obvious
and irrelevant to what I was saying.
VLA failure is not the same as malloc() failure. malloc() has a clear,
portable interface for allocation failure.
Tim said:What you mean is that VLAs have no portably guaranteed failure
mechanism. On a particular implementation they may very well
have a well-defined, implementation-supplied, such mechanism.
Tim said:Completely beside the point I was making, as using malloc() is
no different in this regard.
Rui Maciel said:Is there any implementation that actually implements such
a mechanism?
And if this sort of mechanism isn't required by the standard,
is it a good idea to write code counting on it?
Rui Maciel said:How so?
gwowen said:It doesn't matter. Whatever objection you raise, Tim's
hypothetical compiler will have a convenient fix for it.
Malcolm McLean said:Tim Rentsch:Platform specific code can deal with platform-specific stack overflowMalcolm McLean said:Tim Rentsch:
(e-mail address removed)-berlin.de (Stefan Ram) writes:
You snipped too much context. If a piece of code isn't
able to deal with an allocation failure, it doesn't matter
where the allocation falure came from. If a piece of
code is able to deal with allocation failure in some way,
that applies equally to allocation failures for malloc()
and VLAs, assuming of course that VLA allocation failure
can be detected, which I pointed out upthread that it
can in a conforming implementation, if the implementation
so desires. The ability or non-ability of some piece of
code to respond sensibly to allocation failure has no
bearing on the point I was making.
We're talking about libraries.
I want to find the convex hull of a set of points. The algorithm I'm
using needs a temporary buffer. [snip example]
with a vla it's a bit more difficult to provide a corresponding solution.
You're making basically the same point that you made upthread, to
which I already responded that it's beside the point I was making.
Did you not understand the point I was making? Do you not
understand what it means for something to be beside the point? Do
you think that repeating yourself is going to magically change
whether what you have to say is relevant? The statement above
(the last one in the quoted excerpt) is true but also obvious
and irrelevant to what I was saying.
signals sensibly. Portable code can't. That doesn't mean that portable
code might not be able to pass up an out of memory condition, if it
can detect it. Caller might not be able to do anything sensible if
that happens.
You say
That sounds reasonable, but the devil is in "can be detected". Does it
mean can be detected in the supposedly portable code, at cost of
turning it into mass of conditional compilations, which means that it
can't be tested or modified easily on a platform that doesn't provide
for VLA failures?
VLA failure is not the same as malloc() failure. malloc() has a clear,
portable interface for allocation failure.
Tim:gwowoen:
Ben:
Really? Only if they're (i) of bounded size or (ii) of trivially small
size. Otherwise you're just asking for horrible, undetectable stack
overflow bugs, because VLAs have no failure mechanism.
You're right. But a "well-defined, implementation supplied mechanism" isn'tvery useful, given the way that a lot of C is actually used, which is to create components.What point are you making that's different from the
two I already responded to, saying that your
comments were irrelevant to the point I was making?
Or are you just repeating the same irrelevant comments?
Sorry. I had to go back in the thread, and you seemed to be in the attribution line.I never said that.
Most programs don't have to run on more than a limited set of platforms, often just one.I expect, though, that it
is more common for programs to be closer to the other
end of the spectrum, targeting a particular platform or
a small number of related platforms, and in those cases
the benefits (ie, of using a non-ubiquitous capability)
are more likely to outweigh the costs.
Tim said:My phrasing in that sentence wasn't as good as it might
have been.. sorry about that.
If he's talking about not being able to handle an allocation
failure adequately, it doesn't matter whether the handler runs
as a result of detecting a malloc() failure or detecting a VLA
allocation failure;
If he's talking about malloc() having a standard interface for
detecting allocation failures and VLAs not having such a
mechanism, that's beside the point I was making, since I was
explicitly talking about implementation-specific mechanisms.
Is there any implementation that actually implements such
a mechanism?
Say I write a command line utility to read in a DNA sequence, and scan it for lots of restriction sites (places in the DNA where enzymes cut it). Let's say that the plaform I'm using terminates the program with the nessage "segmentation fault" on stack overflow.Tim Rentsch wrote:
So, what exactly are you talking about? Hypothetical implementation-
specific mechanisms which don't exist in the real world?
Malcolm McLean said:Tim Rentsch:I expect, though, that it
is more common for programs to be closer to the other
end of the spectrum, targeting a particular platform or
a small number of related platforms, and in those cases
the benefits (ie, of using a non-ubiquitous capability)
are more likely to outweigh the costs.
Most programs don't have to run on more than a limited set of
platforms, often just one.
But most components can be written portably. Basically you need to
ask, does this bit of funtionality perform IO? If not, it can be
written in pure ANSI C, and normally it should be written in pure ANSI
C. There is a problem with malloc(), and there are some side issues
with DMA engines and the like which blur the distinction between IO
and processing. [snip elaboration]
Malcolm McLean said:Tim Rentsch:
[snip apparently misquoted previous context]
[in response to upthread posting]
What you mean is that VLAs have no portably guaranteed failure
mechanism. On a particular implementation they may very well
have a well-defined, implementation-supplied, such mechanism
[in response to last posting
What point are you making that's different from the
two I already responded to, saying that your
comments were irrelevant to the point I was making?
Or are you just repeating the same irrelevant comments?
You're right. But a "well-defined, implementation supplied
mechanism" isn't very useful, given the way that a lot of C is
actually used, which is to create components.
You haven't replied to that point, just said "it's
irrelevant", without giving a justification,
except to claim that "malloc is the same", which isn't the
case.
Then you've repeated "you're making irrelevant points" ad
nauseum. Which become irritating after a while.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.