This line should set to 0 one bit of an array (of 32-bit values):
P[[(c>>5)]]&=(!((0x00000001)<<(c2&0x0000001f)));
but it actually sets the whole word to zero.
That's a complex statement you got there. Let's break it down into it's
parts
The RHS breaks down as
(c2 & 0x1f) results in an int between 0 and 31 (assuming c2 is an int)
0x01 << (c2 & 0x1f) results in one of 32 bits being set (assuming that
0x01 is a 32bit integer), making the result non-zero
!(0x01 << (c2 & 0x1f)) results in zero. ! changes zero values to 1 and
non-zero values to 0
So, on the RHS, we have 0 (or some sort of violation, for a non-int c2 or
ints that are smaller than 32bits wide)
The assignment operator is &=, which LOGICAL-ANDs the LHS with the RHS and
assigns the resulting value to the LHS.
Any integer LOGICAL-ANDed with 0 results in 0, so the LHS gets assigned 0
Let's look at that LHS:
P[[(c>>5)]]
Hmmmmm..... that's a notation that I'm unfamiliar with. Pedants and experts,
is that even a legal C construct?
I'm specifically referring to
P[[...]]
an anonymous subscript *within* a subscript?
Since this is obviously logically correct,
Not so obviously. Certainly, it depends on some context, both with other
code (what sort of data items are <<c>> and <<c2>>?) and on the
capabilities of the compiler and environment you are working with (how big
is an int? what does the C compiler think of said:
can C not handle these things? I'm sure I have to
rewrite the whole god-damned thing in assembler.
If you can, and you think that C won't handle the expression you are trying
to build, why don't you rewrite it in Assembler. Certainly, we have no
emotional investment in the languages you choose to write your code in.