JKop wrote:
Now, take your example:
s1.ar = s2.ar;
That is equal to:
&s1.ar[0] = &s2.ar[0];
That's exactly like writing:
unsigned int k = 4;
&k = 27873;
You're not changing the value of a variable at all! You're trying to change
the address of a variable! Self-explanatory I hope!
...
This doesn't really explain much. Yes, the standard array-to-pointer
conversion is the immediate formal reason why such code won't compile,
but the _real_ question is why array assignment (and array copying)
contexts were not excluded from the list of contexts where
array-to-pointer conversion is applied. Today there is no formal reason
for it to be this way, although there probably was one a rather long
time ago.
There is no technical problems with requiring the language to perform
array assignment in
s1.ar = s2.ar;
But doing this will break the compatibility with previous version of
language specification.
Note also that one specific array-related context does actually copy arrays:
char lpsz[] = "Hello world";
--
Best regards,
Andrey Tarasevich