Re: Keil c51 interprets &Array as Array. Is that normal?

"Andrey Tarasevich" <andreytarasevich@xxxxxxxxxxx> wrote in message
Tim Wescott wrote:
On Thu, 10 Apr 2008 12:57:46 -0700, Andrey Tarasevich wrote:

If you want to obtain a "pointer-to-array-of-N-char" in this example, you
need to use the unary '&' explicitly. The following expression


does in fact evaluate to a value of "pointer-to-array-of-N-char" type,
which is 'char (*)[10]' in this case. And the compiler will not
"seamlessly cast" it to "pointer-to-char" type

b = &a; /* ERROR !!! */

as you seem to suggest in your previous message. This is why I disagreed
with it.

Best regards,
Andrey Tarasevich

OK, I think we have flogged this to death now. Keil is naughty to treat "p
= &Array" and "p = Array" as the same without any warning, but apart from
that, it may as well treat the two assigments as the same, though the latter
better reflects what is intended.

Of course, if it was:

char *Array = malloc(n); // Used to be fixed size, but we progressed. */
/* masses of obscuring data declarations */
char *p1 = Array;
char *p2 = &Array; /* Someone may be in for a nasty shock when they use
*p2 to access Array[0] */

then things might be more troubled. And yes, Keil compiles this without a
murmur too. Thank heavens for PCLInt.



Relevant Pages

  • Re: Overloading of operator names - opinions sought
    ... possible, but it is more likely that the known cases will be known to the compiler implementer, and hence will be better optimized. ... char and bool are also special integer types. ... would either require some special stropping syntax, context dependence, ... with the realization that I would need multiple casts due to differences in semantics. ...
  • Re: Replacing fgets
    ... Even if u_int8_t is a typedef for unsigned char, ... Didn't your compiler complain here. ... offset is changed ... offset needs to be an int. ...
  • Re: howto get rid of pointer arguments differ in signedness
    ... why don't you provide some argument supporting your 'total ... disagreement' with the idea that C-compilers should support ... Since the specification is ten years younger than 'the compiler', ... char and unsigned char are three mutually incomaptible types, ...
  • Re: Need support for the IBM support
    ... So the only compiler we have is XL eval with the most recent patches. ... provide a freely-accessible bug reporting web page, ... int main(int argc, char *argv) { ... this=2ff224a0 S(const char* char array) ...
  • Re: constant string as controlling expression in _Generic gives error
    ... Probably because the developers of the compiler you're using ... a pointer -- but the standard doesn't say so. ... char[]) are not permitted, there's no good way to match an array as the ...