Re: Valid optimization with constant arrays

2008-11-18 Thread Joe Buck
On Mon, Nov 17, 2008 at 06:46:38PM -0800, Andrew Pinski wrote: > 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; > } Note that in the above function, called

Re: Valid optimization with constant arrays

2008-11-17 Thread Joseph S. Myers
On Mon, 17 Nov 2008, Andrew Pinski wrote: > 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 I don't know what you mean by "normative note" ("In accordance with Part 3 of the ISO/IEC Directives, this forewo

Valid optimization with constant arrays

2008-11-17 Thread Andrew Pinski
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