Sys_query_cache_limit variable has query_cache.query_cache_limit as a place to write its value to. But it's a member of a class that has constructor and so initialization of Sys_query_cache_limit (which assigns default value to the variable) is dependent on initialization of query_cache to happen earlier. As these variables are in different source files order of initialization between them is not defined.
The attached patch fixes Sys_query_cache_limit to point to global variable instead of class member.
Detected by new feature of AddressSanitizer – check_initialization_order.