-Wmaybe-uninitialized leads to build failures
Issue #132
new
There a multiple functions in Papi which when compiled with -O3 -Wall -Werror fail to build. This currently stops upgrading the papi package for Ubuntu.
The full build log is here: https://launchpadlibrarian.net/648311749/buildlog_ubuntu-lunar-ppc64el.papi_7.0.0-2_BUILDING.txt.gz
Let’s use src/components/sde/tests/Simple2/Simple2_Lib.c as an example. Here we find:
// This function allows the library to perform operations in order to compute the value of an SDE at run-time
long long counter_accessor_function( void *param ){
long long *ll_ptr;
double *dbl_ptr = (double *)param;
// Scale the variable by a factor of two. Real libraries will do meaningful work here.
double value = *dbl_ptr * 2.0;
// Pack the bits of the result in a long long int.
ll_ptr = (long long *)&value;
return *ll_ptr;
}
As ll_ptr and value are of different type and none of both is a charlike array the sequence of the assignments to ll_ptr and to value is undefined behavior. This can be avoided by either adding a barrier or by using a union:
// This function allows the library to perform operations in order to compute the value of an SDE at run-time
long long counter_accessor_function( double *param ){
double *dbl_ptr = param;
union {
double d;
long long l;
} value;
// Scale the variable by a factor of two. Real libraries will do meaningful work here.
value.d = *dbl_ptr * 2.0;
return value.l;
}
Best regards
Heinrich
Comments (4)
-
-
@Anthony Danalis
-
reporter On 5/11/23 10:16, Giuseppe Congiu wrote:
Launchpad deletes autopkgtest logs after some time.
-
-
assigned issue to
-
assigned issue to
- Log in to comment
I can’t download the log. There is something wrong with it.