[ILUG] gcc optimisation weirdness?
Paul Jakma
paulj at itg.ie
Wed May 10 18:14:26 IST 2000
On Wed, 10 May 2000, Kenn Humborg wrote:
>
> Very odd... I'd expect that the statement
>
> (f[i])++
>
> would not be legal. Is (var) a legal lvalue? Aha... info gcc
well i initially didn't have brackets. I added them because it seemed
that with:
frequency[input+1]++;
gcc was somehow mis-optimising the ++, so i added the () to try to make it
explicit that i wanted frequency[input-1] evaluated first, and the
increment to be applied to frequency[..].
[snip gcc info]
i'm not doing anything funky like these examples above. i'm just trying to
be explicit about the ordering wrt to the ++ operator.
> > PS: is there anyway to initialise an array at declaration time, rather
> > than iterate thru the array and set each element manually? eg something
> > like: int array[9]=0;
>
> You mean like:
>
> int array[9]={0, 1, 2, 3, 4, 3, 2, 1, 0};
>
> That is standard C.
doh! i'm rusty... just coulnd't remember it.
> GCC also has some extensions that allow
> you to do fancied stuff with initializers.
the : operator, right? don't remember exactly how it works, but something
like:
struct foo {
int var : 0;
char bar : NULL;
} foobar;
it used in a few places in the linux source.
> Take a look at
> the C and C++ Extensions sections in the GCC info pages.
>
still can't understand exactly where "gcc test.c" is fscking up or why,
when "gcc -Ox" works as expected.
How's your x86 asm? :)
> Later,
> Kenn
>
More information about the ILUG
mailing list