Re: Order of evaluation.
From: Jason (spacenjasset_at_fastmail.fm)
Date: 02/11/04
- Next message: André Pönitz: "Re: Order of evaluation."
- Previous message: osmium: "Re: Order of evaluation."
- In reply to: Richard Heathfield: "Re: Order of evaluation."
- Next in thread: B. v Ingen Schenau: "Re: Order of evaluation."
- Reply: B. v Ingen Schenau: "Re: Order of evaluation."
- Reply: Richard Heathfield: "Re: Order of evaluation."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 11 Feb 2004 16:02:51 -0000
"Richard Heathfield" <invalid@address.co.uk.invalid> wrote in message
news:402a4aec@news2.power.net.uk...
> To be frank, neither do I! That is, I know it's either unspecified
behaviour
> or undefined behaviour. I suspect the latter, but can't prove it without
> digging out the Standard (and I might just end up proving myself wrong).
> But the *important* thing about the code, the "right" answer if you like,
> is "this code is stupid stupid stupid and don't /ever/ let me catch you
> doing this, okay?". :-)
I won't do that. I would do a++ before calling the function.
> It does indeed. If the interviewer doesn't know that this is valid, and
> *why* it is valid, he or she has no business testing other people's C
> knowledge.
That is how I feel, although I appreciate that someone that knows the finer
points of C, will most proably be a "well rounded" programmer.
> > Sophos have a reputation for "difficult" C tests, but I find it strange
> > that they don't know about the above construct.
>
> It seems they find C rather difficult.
>
>
> > Good job I didn't write this then, which I believe is also valid, but
> > unnecessary ( sizeof introduces the tag name a_struct in this context ):
> >
> > {
> > size_t size = sizeof ( struct a_struct { int a; } );
> >
> > s = malloc( sizeof (a_struct) );
> > }
>
> I think you might want to run this one by your compiler before you get too
> fond of it. :-)
Ah - it doesn't work then? I am not fond of it (never tried it). I read that
in 1994, Samuel P. Harbison, et al., "C A Reference Manual", ISBN
0-13-326224-3, page 196
"The effect of sizeof(struct S {int a,b;} ) is to create a new type [S] in
ISO C, [cut], the type can be referenced later in the source file."
Took me ages to find that reference.
- Next message: André Pönitz: "Re: Order of evaluation."
- Previous message: osmium: "Re: Order of evaluation."
- In reply to: Richard Heathfield: "Re: Order of evaluation."
- Next in thread: B. v Ingen Schenau: "Re: Order of evaluation."
- Reply: B. v Ingen Schenau: "Re: Order of evaluation."
- Reply: Richard Heathfield: "Re: Order of evaluation."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|