Re: Array parameter causes undefined behavior?
- From: REH <spamjunk@xxxxxxxxxxx>
- Date: Tue, 20 Oct 2009 10:02:59 -0700 (PDT)
On Oct 20, 12:22 pm, "Johannes Schaub (litb)" <schaub-johan...@xxxxxx>
wrote:
(This was sent to comp.lang.c++.moderated, but as there is the same
restriction in C, i send it to this one too.) What is the reason that the
following code causes undefined behavior?
// undefined behavior
void f(char const paramN[], ...) {
va_list ap;
va_start(ap, paramN);
va_end(ap);
}
As far as i can see, that's just a parameter with type "char const*". What's
the reason of treating it different? 7.15.1.4/4 in n1256:
"If the parameter parmN is declared with the register storage class, with a
function or array type, or with a type that is not compatible with the type
that results after application of the default argument promotions, the
behavior is undefined."
What about function or arrays? Is there some old implementation that
actually behaved in some strange way?
paramN is not an array. It is a pointer. Also note that "function
type" does not include function pointer type.
REH
.
- Follow-Ups:
- Re: Array parameter causes undefined behavior?
- From: Wojtek Lerch
- Re: Array parameter causes undefined behavior?
- References:
- Array parameter causes undefined behavior?
- From: Johannes Schaub (litb)
- Array parameter causes undefined behavior?
- Prev by Date: Array parameter causes undefined behavior?
- Next by Date: Re: Array parameter causes undefined behavior?
- Previous by thread: Array parameter causes undefined behavior?
- Next by thread: Re: Array parameter causes undefined behavior?
- Index(es):
Relevant Pages
|