
/* Check that very long function names are safely truncated in 
   memcheck's XML output. */

#if defined(_AIX)

#include <stdio.h>
int main () { 
   printf("This test is not compilable on AIX using gcc.\n");
   return 0;
}



#else

#define N1 [encoded data, 5304 characters]

#define N2 [encoded data, 5304 characters]

#include <iostream>
#include <stdlib.h>
#include <stdint.h>

using namespace std;

// A function that returns p in such a way that gcc 4.5.x does not recognize
// that it returns p. Prevents that the optimizer throws the assignment away
// that occurs just before the free() call.
static char* idem(char* p) { return (char*)((uintptr_t)p * 2 / 2); }

namespace N1 {
  namespace N2 {
    void f() {
      cout << "I'm in an asininely long namespace!" << endl;
      char *ptr = (char *)malloc (4);
      idem(ptr)[5] = 0;
      free(ptr);
    }
  }
}

int main() {
  N1::N2::f();
  return 0;
}

#endif /* defined(_AIX) */
