Gtest with C ++ 11 std :: condition_variable implies valgrind errors

If I write a test using the Google Test Framework this way:

TEST_F( TestFName, TestName )
{
     std::condition_variable cv;
}

It generates a valgrind error. I run it with options --leak-check=full --track-origins=yes.

Conditional jump or move depends on uninitialised value(s)
==17215==    at 0x4E3DA82: pthread_cond_destroy@@GLIBC_2.3.2 (pthread_cond_destroy.c:35)
...
 Uninitialised value was created by a stack allocation
==17215==    at 0x4551D0: TestFName_TestName_test::TestBody()

It was strange to realize that the error came from an announcement condition_variable cv. When I declared global, the error disappeared.

I am running Valgrind-3.7.0 on a machine with Ubuntu 3.8 x86_64.

Has anyone else encountered the same problem?

+4
source share
1 answer

, , , , libstd++. , libstd++ _GTHREAD_USE_COND_INIT_FUNC, .

: <condition_variable> , pthread_cond_t. __GTHREAD_COND_INIT, , . , , . __GTHREAD_COND_INIT, _GTHREAD_USE_COND_INIT_FUNC.

g++, , , . , , , , libstd++ _GTHREAD_USE_COND_INIT_FUNC undefed, -. , , .

, :

+3

Source: https://habr.com/ru/post/1526132/


All Articles