android_mt6572_jiabo/ndk/tests/device/multi-static-instances/jni/main.cpp
2025-09-05 16:56:03 +08:00

24 lines
561 B
C++

/* This file is here to check for the following bug report:
* http://code.google.com/p/android/issues/detail?id=16010
*/
#include <stdio.h>
class A {
public:
static A* instance() {
static A _instance;
return &_instance;
}
};
int main() {
A* first = A::instance();
A* second = A::instance();
if (first != second) {
fprintf(stderr, "ERROR: instance() returned two distinct addresses: %p %p\n", first, second);
return 1;
}
printf("OK: instance() returned the same address twice: %p\n", first);
return 0;
}