- changed status to open
- removed comment
LocalReduce: Initialize variables to avoid compiler warnings
The following one-line change would initialize the inval variable, avoiding compiler warnings for almost all variable types.
Index: local_reductions.h
--- local_reductions.h (revision 86) +++ local_reductions.h (working copy) @@ -32,6 +32,7 @@ iter = 0; \ sum_indices = 0; \ num_points = 1; \ + REDUCTION_INITIAL(inval) \ REDUCTION_INITIAL( * outval) \ \ if ( N_dims == 0 ) \
Keyword:
Comments (7)
-
reporter -
- removed comment
This seems to be a harmless change.
Why does the compiler warn?
-
reporter - removed comment
Potential use of uninitialized memory
-
- removed comment
I mean, is this a real possibility in the source code, or is the compiler just not clever enough to understand the source code? I notice e.g. some funny games with .Re and .Im and complex numbers.
-
reporter - removed comment
It complains about .Im, also for non-complex variable types, so I assume it's the compiler not understanding the logic. However, I didn't look too closely and it might actually access .Im even for non-complex types. It doesn't look bad to me to initialize that memory in any case, and it also does not look like it would affect performance in any measurable way (by looking at the code, not by trying to measure it).
-
- removed comment
There is a bit of complexity since e.g. the L2 norm of complex numbers results in a real number. I don't know how/whether the code handles this.
I also remember that some of the reduction operations give wrong values for complex numbers.
The patch seems harmless, please apply.
-
- changed status to resolved
- removed comment
Applied.
- Log in to comment