From 3f52132a8f901aeb6c6e3449f1ef652a2b094e09 Mon Sep 17 00:00:00 2001 From: xavier Date: Thu, 13 Jan 2022 09:20:38 +0100 Subject: [PATCH] tests: include global initializers in c++ compiler test --- test/standalone/c_compiler/test.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/standalone/c_compiler/test.cpp b/test/standalone/c_compiler/test.cpp index f10a9e0c00..8c533d02cc 100644 --- a/test/standalone/c_compiler/test.cpp +++ b/test/standalone/c_compiler/test.cpp @@ -12,15 +12,22 @@ private: int m_val; }; + +volatile int runtime_val = 456; +CTest global(runtime_val); // test if global initializers are called. + int main (int argc, char *argv[]) { + assert(global.getVal() == 456); + auto* t = new CTest(123); assert(t->getVal()!=456); - if (argc>1) t->printVal(); + + if (argc>1) t->printVal(); bool ok = t->getVal() == 123; delete t; - if (!ok) abort(); + if (!ok) abort(); return 0; }