my fussy compiler likes explicit casts
James Theiler
jt@lanl.gov
Thu Feb 13 03:01:00 GMT 2003
I'm trying to compile GSL using Parasoft's insure++ leak detector,
which is generally fussier than many other compilers. It complained
about some type conversions in three (but only three out of hundreds!)
of GSL files, and all three were quickly fixed by appropriate casting,
and I have attached patches for the changes. The files are
cblas/source_cgemm_c.h
ntuple/ntuple.c
ode-initval/cscal.c
Someone who understands casting better than I (especially when const's
are involved) might want to look these over before applying them.
There may be better/deeper philosophical reasons not to employ
explicit casts, but they permit the compiler to work for me.
The last one (cscal.c) also required that I explicitly add
an '#include <string.h>' in order for it to understand memcpy();
again, maybe this is parasoft-specific and we should depend on
configure to keep that straight.
regards,
jt
---------------------------------------------
James Theiler jt@lanl.gov
MS-D436, NIS-2, LANL tel: 505/665-5682
Los Alamos, NM 87545 fax: 505/665-4414
----- Space and Remote Sensing Sciences -----
-------------- next part --------------
*** gsl-1.3/cblas/source_gemm_c.h Fri Apr 27 13:06:44 2001
--- gsl-1.3-fixed/cblas/source_gemm_c.h Tue Feb 11 08:53:52 2003
***************
*** 37,58 ****
if (Order == CblasRowMajor) {
n1 = M;
n2 = N;
! F = A;
ldf = lda;
conjF = (TransA == CblasConjTrans) ? -1 : 1;
TransF = (TransA == CblasNoTrans) ? CblasNoTrans : CblasTrans;
! G = B;
ldg = ldb;
conjG = (TransB == CblasConjTrans) ? -1 : 1;
TransG = (TransB == CblasNoTrans) ? CblasNoTrans : CblasTrans;
} else {
n1 = N;
n2 = M;
! F = B;
ldf = ldb;
conjF = (TransB == CblasConjTrans) ? -1 : 1;
TransF = (TransB == CblasNoTrans) ? CblasNoTrans : CblasTrans;
! G = A;
ldg = lda;
conjG = (TransA == CblasConjTrans) ? -1 : 1;
TransG = (TransA == CblasNoTrans) ? CblasNoTrans : CblasTrans;
--- 37,58 ----
if (Order == CblasRowMajor) {
n1 = M;
n2 = N;
! F = (const BASE *)A;
ldf = lda;
conjF = (TransA == CblasConjTrans) ? -1 : 1;
TransF = (TransA == CblasNoTrans) ? CblasNoTrans : CblasTrans;
! G = (const BASE *)B;
ldg = ldb;
conjG = (TransB == CblasConjTrans) ? -1 : 1;
TransG = (TransB == CblasNoTrans) ? CblasNoTrans : CblasTrans;
} else {
n1 = N;
n2 = M;
! F = (const BASE *)B;
ldf = ldb;
conjF = (TransB == CblasConjTrans) ? -1 : 1;
TransF = (TransB == CblasNoTrans) ? CblasNoTrans : CblasTrans;
! G = (const BASE *)A;
ldg = lda;
conjG = (TransA == CblasConjTrans) ? -1 : 1;
TransG = (TransA == CblasNoTrans) ? CblasNoTrans : CblasTrans;
*** gsl-1.3/ntuple/ntuple.c Wed Apr 18 15:52:34 2001
--- gsl-1.3-fixed/ntuple/ntuple.c Tue Feb 11 09:34:33 2003
***************
*** 32,38 ****
gsl_ntuple *
gsl_ntuple_create (char *filename, void *ntuple_data, size_t size)
{
! gsl_ntuple *ntuple = malloc (sizeof (gsl_ntuple));
if (ntuple == 0)
{
--- 32,38 ----
gsl_ntuple *
gsl_ntuple_create (char *filename, void *ntuple_data, size_t size)
{
! gsl_ntuple *ntuple = (gsl_ntuple *)malloc (sizeof (gsl_ntuple));
if (ntuple == 0)
{
***************
*** 62,68 ****
gsl_ntuple *
gsl_ntuple_open (char *filename, void *ntuple_data, size_t size)
{
! gsl_ntuple *ntuple = malloc (sizeof (gsl_ntuple));
if (ntuple == 0)
{
--- 62,68 ----
gsl_ntuple *
gsl_ntuple_open (char *filename, void *ntuple_data, size_t size)
{
! gsl_ntuple *ntuple = (gsl_ntuple *)malloc (sizeof (gsl_ntuple));
if (ntuple == 0)
{
*** gsl-1.3/ode-initval/cscal.c Fri Jul 26 16:08:29 2002
--- gsl-1.3-fixed/ode-initval/cscal.c Tue Feb 11 09:20:29 2003
***************
*** 19,24 ****
--- 19,25 ----
#include <config.h>
#include <stdlib.h>
+ #include <string.h>
#include <math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_math.h>
***************
*** 176,182 ****
{
sc_control_state_t * s = (sc_control_state_t *) c->state;
! s->scale_abs = malloc(dim * sizeof(double));
if (s->scale_abs == 0)
{
--- 177,183 ----
{
sc_control_state_t * s = (sc_control_state_t *) c->state;
! s->scale_abs = (double *)malloc(dim * sizeof(double));
if (s->scale_abs == 0)
{
More information about the Gsl-discuss
mailing list