Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-13 Thread Jeffrey Walton
Can someone help me understand what's going on? I really enjoyed the sidebars. (Thanks for tolerating the color commentary). But to get back to the question on the findings, why would Valgrind complain a boolean value is not initialized, even though its initialized to false in the source code

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-13 Thread Jeffrey Walton
On Thu, Aug 13, 2015 at 1:38 AM, Bart Van Assche bvanass...@acm.org wrote: On 08/12/15 22:18, Jeffrey Walton wrote: Its *really* pathetic the C++ language lacks a mechanism for me to say Object 1 depends upon String 1, 2, 3, and Object 2 depends upon Object 1 and String 1, 2, 3. What's

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-13 Thread Dan Kegel
Am 13.08.2015 12:48 vorm. schrieb Jeffrey Walton noloa...@gmail.com: ... But to get back to the question on the findings, why would Valgrind complain a boolean value is not initialized, even though its initialized to false in the source code and backed via BSS? It would help if you could post

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-13 Thread David Chapman
On 8/12/2015 10:18 PM, Jeffrey Walton wrote: On Wed, Aug 12, 2015 at 6:02 PM, David Chapman dcchap...@acm.org wrote: On 8/12/2015 1:09 PM, Dan Kegel wrote: ... So even though I just told you how to guarantee that global variables in C++ are initialized before they are used, don't do it. :-)

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-13 Thread Dan Kegel
On Wed, Aug 12, 2015 at 10:38 PM, Bart Van Assche bvanass...@acm.org wrote: What's wrong with the singleton pattern ? Less, now :-) See http://preshing.com/20130930/double-checked-locking-is-fixed-in-cpp11/ - Dan --

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-13 Thread Milian Wolff
On Thursday, August 13, 2015 07:29:22 AM Jeffrey Walton wrote: Just venting here, but... $ ls *.h *.cpp | wc -l 269 $ grep class *.h *.cpp | wc -l 1332 Of 1300+ classes and nearly 270 source files, there are 5 globals that are sensitive to their

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-13 Thread Julian Seward
On 13/08/15 10:03, Dan Kegel wrote: It would help if you could post a complete example so others could see it in action. Have you tried hacking it down until it fits in a teacup? +1 for that. J --

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-13 Thread Jeffrey Walton
On Thu, Aug 13, 2015 at 12:06 PM, Dan Kegel d...@kegel.com wrote: On Thu, Aug 13, 2015 at 6:11 AM, Jeffrey Walton noloa...@gmail.com wrote: Al we have managed to do since C++98 (maybe earlier) is move the problem around because the C++ language has not given us the tools we need to address the

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-13 Thread David Chapman
On 8/13/2015 10:28 AM, Jeffrey Walton wrote: On Thu, Aug 13, 2015 at 12:06 PM, Dan Kegel d...@kegel.com wrote: On Thu, Aug 13, 2015 at 6:11 AM, Jeffrey Walton noloa...@gmail.com wrote: Al we have managed to do since C++98 (maybe earlier) is move the problem around because the C++ language has

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-13 Thread Dan Kegel
On Thu, Aug 13, 2015 at 3:30 PM, Jeffrey Walton noloa...@gmail.com wrote: I tracked it down to a one-liner ASM statement. The CPUID instruction's ASM block was missing volatile. I guess the optimizer removed it, which confused the machinery. (The other values were initialized, like the global

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-13 Thread Dan Kegel
On Thu, Aug 13, 2015 at 6:11 AM, Jeffrey Walton noloa...@gmail.com wrote: Al we have managed to do since C++98 (maybe earlier) is move the problem around because the C++ language has not given us the tools we need to address the problem. What part of stop doing that does C++ get in the way of?

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-12 Thread Jeffrey Walton
On Wed, Aug 12, 2015 at 4:09 PM, Dan Kegel d...@kegel.com wrote: On Wed, Aug 12, 2015 at 12:58 PM, Jeffrey Walton noloa...@gmail.com wrote: The C++ object that uses it is in another translation unit, and it has a init_pritority attribute. File-scope or static C++ objects are the spawn of the

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-12 Thread Dan Kegel
On Wed, Aug 12, 2015 at 12:58 PM, Jeffrey Walton noloa...@gmail.com wrote: The C++ object that uses it is in another translation unit, and it has a init_pritority attribute. File-scope or static C++ objects are the spawn of the devil. There is no reliable or portable way to control

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-12 Thread Ivan Skytte Jørgensen
On Wednesday 12 August 2015 15:58:36 Jeffrey Walton wrote: The variable that is triggering the uninitialized access is a simple flag and I believe it is initialized: bool g_flag = false; The C++ object that uses it is in another translation unit, and it has a init_pritority attribute.

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-12 Thread Dan Kegel
On Wed, Aug 12, 2015 at 1:32 PM, Jeffrey Walton noloa...@gmail.com wrote: The GCC folks told me to use init_priority for these issues. See Method to specify initialization order across translation units? (https://gcc.gnu.org/ml/gcc-help/2015-08/msg00025.html). I bet they were thinking ... and

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-12 Thread David Chapman
On 8/12/2015 1:09 PM, Dan Kegel wrote: On Wed, Aug 12, 2015 at 12:58 PM, Jeffrey Walton noloa...@gmail.com wrote: The C++ object that uses it is in another translation unit, and it has a init_pritority attribute. File-scope or static C++ objects are the spawn of the devil. There is no

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-12 Thread Jeffrey Walton
On Wed, Aug 12, 2015 at 6:02 PM, David Chapman dcchap...@acm.org wrote: On 8/12/2015 1:09 PM, Dan Kegel wrote: ... So even though I just told you how to guarantee that global variables in C++ are initialized before they are used, don't do it. :-) Refactoring sounds expensive but in the long

Re: [Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-12 Thread Bart Van Assche
On 08/12/15 22:18, Jeffrey Walton wrote: Its *really* pathetic the C++ language lacks a mechanism for me to say Object 1 depends upon String 1, 2, 3, and Object 2 depends upon Object 1 and String 1, 2, 3. What's wrong with the singleton pattern ? When using the singleton pattern non-circular

[Valgrind-users] Uninitialized access findings on non-static file scope variables that's been initialized?

2015-08-12 Thread Jeffrey Walton
I'm catching an uninitialized access on a non-static variable that has file scope in a C++ translation unit. I'm having trouble interpreting the finding. The variable that is triggering the uninitialized access is a simple flag and I believe it is initialized: bool g_flag = false; The C++