28 lines · cpp
1// Constexpr:2// We need to check that a global variable initialized with a constexpr3// constructor can be accessed during dynamic initialization (as a constexpr4// constructor implies that it was initialized during constant initialization,5// not dynamic initialization).6 7// RUN: %clangxx_asan -O0 %s %p/Helpers/initialization-constexpr-extra.cpp --std=c++11 -o %t8// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&19// RUN: %clangxx_asan -O1 %s %p/Helpers/initialization-constexpr-extra.cpp --std=c++11 -o %t10// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&111// RUN: %clangxx_asan -O2 %s %p/Helpers/initialization-constexpr-extra.cpp --std=c++11 -o %t12// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&113// RUN: %clangxx_asan -O3 %s %p/Helpers/initialization-constexpr-extra.cpp --std=c++11 -o %t14// RUN: %env_asan_opts=check_initialization_order=true %run %t 2>&115 16class Integer {17private:18 int value;19 20public:21 explicit constexpr Integer(int x = 0) : value(x) {}22 int getValue() {return value;}23};24Integer coolestInteger(42);25int getCoolestInteger() { return coolestInteger.getValue(); }26 27int main() { return 0; }28