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



Robert Adsett wrote:
On Apr 11, 5:22 am, "Bill Davy" <B...@xxxxxxxxxxxxxxx> wrote:
{
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] */
}

Why would someone be in for a shock using p2? The generated code
should be the same even though there is a type mismatch in the
assignment.

mspgcc shouts "main.c:45: warning: assignment from incompatible pointer type"

which is about right.
.



Relevant Pages

  • Re: why one array continues to grow after repeated call
    ... It just so happens that the semantics of the = method on an Array ... But objects mutating is completely different to assignment. ... reference to some object), and store this reference in the local ... char *a; ...
    (comp.lang.ruby)
  • Re: ISO Open Array Parameters
    ... to an open array parameter as a whole ... PROCEDURE P(VAR a:ARRAY OF CHAR); ... other character array variable, no matter what the declared size. ... string literal assignment is an exceptional case. ...
    (comp.lang.modula2)
  • Using &array with scanf
    ... I know this is wrong because it's a type mismatch, ... a pointer to char and gets a pointer to an array of 20 char. ...
    (comp.lang.c)
  • Re: Keil c51 interprets &Array as Array. Is that normal?
    ... devolve to pointer to char in context (A pointer to an array is a ... pointer to the first member of that array). ... mismatches but the practical effect is only the type mismatch in most ... to char or pointer to array of char. ...
    (comp.arch.embedded)
  • Re: Keil c51 interprets &Array as Array. Is that normal?
    ... devolve to pointer to char in context (A pointer to an array is a ... pointer to the first member of that array). ... mismatches but the practical effect is only the type mismatch in most ... to char or pointer to array of char. ...
    (comp.arch.embedded)