Re: C FAQ 3.1
- From: pete <pfiland@xxxxxxxxxxxxxx>
- Date: Wed, 11 May 2005 17:03:40 GMT
Purnank wrote:
>
> "Stan Milam" <stmilam@xxxxxxxxxx> wrote in message
> news:37qbe.768$m85.35@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > Peter Nilsson wrote:
> > > ccwork wrote:
> > >
> > >>Hi all,
> > >
> > >>Why can't it be unspecified?
>
> <snip>
> discusssion is about
> int i = 7;
> printf("%d\n", i++ * i++);
> prints 49. Regardless of the order of evaluation, shouldn't it print
> 56?
>
> I think this is interesting.
> What metrics can we use to determine it is
> undefined or unspecified?
It violates a "shall constraint" and is undefined.
N869
6.5 Expressions
[#2] Between the previous and next sequence point an object
shall have its stored value modified at most once by the
evaluation of an expression.
> > > The real question is: Why _should_ it be specified?
> > Because it would clear up a lot of confusion,
> > specify exactly what the behavior should be.
> > I am convinced we have undefined behavior because
> > K&R were too lazy or in a hurry to specify exactly
> > what should happen in these now undefined cases.
It would only add to your confusion.
Code which exhibits undefined behavior like that,
is so substandard, that it is actually not C code.
It's just gibberish that looks like C code.
--
pete
.
- References:
- Re: C FAQ 3.1
- From: Purnank
- Re: C FAQ 3.1
- Prev by Date: Re: lex and yacc
- Next by Date: Re: Calculator
- Previous by thread: Re: C FAQ 3.1
- Index(es):
Relevant Pages
|