On 14/09/2010 19:47, Uday P. Khedker wrote:

> But may be you are right, what facilitate dead code elimination
> be based on modification of read-only data. However, if that is
> the case, I wonder what is the reason why change happens when s is
> an array...

  Because the array, unlike the string, isn't const.

char *s = (char *)"string";

-> s is a pointer to a string (that the compiler happens to know is constant).

char s[] = "string";

-> s is an array of non-constant chars, initialised at startup from a string
constant; it's the same as writing

char s[] = { 's', 't', 'r', 'i', 'n', 'g', '\0' };

  Arrays and pointers are not the same thing in C!

    cheers,
      DaveK

Reply via email to