I noticed that for a simple testcase: int t; void abort (void); int f(int t, const int *a) { const int b[] = { 1, 2, 3}; if (!t) return f(1, b); return b == a; }
int main(void) { if (f(0, 0)) abort (); return 0; } --- CUT --- That before 4.0 gives a different result from 4.0 and above. Is it valid in this case to promote b to a static variable and have f return true when called with f(0, 0) ? I think C99 does allows this optimization (at least according to the normative note 112) but C++ does not. I could not find anything in C++ standard which says the compiler could put the const object in a read-only section but I could be missing something somewhere. Thanks, Andrew Pinski