Comment 6 for bug 1248753

Revision history for this message
David Mathog (mathog) wrote :

I always try to initializ variables when doing so makes sense. Notice that the pointers to various types of memory blobs px, rgba_px, and mempng.buffer are all initialized, because during processing these memory blobs either appear or they don't.
I added an initialization for dibparams because there was a remote possibility that it might actually be used uninitialized. The variables that clang is incorrectly (as far as I can tell) complaining about are not initialized because there is no valid default value to set them to. Sure, they could all be set to zero, or -1, but is the code more correct if it sets values for image width and length that are nonphysical?

I would be more concerned if I were the clang users about finding out why clang is giving these warnings. At most it should say that these variables MIGHT be used uninitialized, which is as much as it should be able to determine since it cannot know what goes on inside the called functions. Instead it says they ARE being used uninitialized, and that is just wrong if the code compiles properly I have been around long enough to have seen several instances where compilers did not actually generate valid instructions. It is unlikely, but possible, that this code is uncovering a clang compiler error such that clang generated code really would use those variables uninitialized, for instance, by not calling wget_dib_params before calling calling DIB_to_RGBA. If clang is working consistently, these warnings should be showing up for emf-inout.cpp too, as there are nearly identical functions there, which Johan must tell me as I don't use clang.

Johan, what happens when clang compiles this fragment?

int test1(int *var); // prototype
int test2(int var); // prototype

int var;
if(test1(&var)){
   std::cout << "Result: " << test2(var) << std::endl;
}