Bug 16389 - incorrect declaration of F77_NAME(dppsvx): 'fact' should be const char*, not const int*.
Summary: incorrect declaration of F77_NAME(dppsvx): 'fact' should be const char*, not ...
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Add-ons (show other bugs)
Version: R 3.2.0
Hardware: Other Linux-Ubuntu
: P5 major
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-05-15 23:53 UTC by Bill Dunlap
Modified: 2015-05-15 23:53 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Dunlap 2015-05-15 23:53:58 UTC
In RHOME/include/R_ext/Lapack.h there is the declaration:

/* DPPSVX - use the Cholesky factorization A = U**T*U or A = */
/* L*L**T to compute the solution to a real system of linear */
/* equations  A * X = B, */
La_extern void
F77_NAME(dppsvx)(const int* fact, const char* uplo,
                 const int* n, const int* nrhs, double* ap,
                 double* afp, char* equed, double* s,
                 double* b, const int* ldb,
                 double* x, const int* ldx,
                 double* rcond, double* ferr, double* berr,
                 double* work, int* iwork, int* info);

but the docs for lapack (e.g., http://www.math.utah.edu/software/lapack/lapack-d/dppsvx.html) say the first argument is a Fortran character (C/C++ char*):

SYNOPSIS
      SUBROUTINE DPPSVX( FACT, UPLO, N, NRHS, AP, AFP, EQUED, S,
                         B, LDB, X, LDX, RCOND, FERR, BERR, WORK,
                         IWORK, INFO )

          CHARACTER      EQUED, FACT, UPLO

          INTEGER        INFO, LDB, LDX, N, NRHS

          DOUBLE         PRECISION RCOND

          INTEGER        IWORK( * )

          DOUBLE         PRECISION AFP( * ), AP( * ), B( LDB, * ),
                         BERR( * ), FERR( * ), S( * ), WORK( * ),
                         X( LDX, * )

and goes on to say
1. If FACT = 'E', real scaling factors are computed ...
2. If FACT = 'N' or 'E', the Cholesky ...

This causes a warning when compiling C++ code that properly passes a pointer to a char for 'fact'. 
% cat callDppsvx.cpp
#include <R_ext/Lapack.h>
void myCholSolve()
{
    const char fact='E'; const char* uplo=0;
    const int* n=0; const int* nrhs=0; double* ap=0;
    double* afp=0; char* equed=0; double* s=0;
    double* b=0; const int* ldb=0;
    double* x=0; const int* ldx=0;
    double* rcond=0; double* ferr=0; double* berr=0;
    double* work=0; int* iwork=0; int* info=0;

    F77_NAME(dppsvx)(&fact, uplo, n, nrhs, ap, afp, equed, s, b, ldb, x, ldx, rcond, ferr, berr, work, iwork, info);
}
% R-3.2.0 CMD SHLIB -o callDppsvx.so callDppsvx.cpp
g++ -I/opt/sw/R/R-3.2.0/lib64/R/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O2  -c callDppsvx.cpp -o callDppsvx.o
callDppsvx.cpp: In function ‘void myCholSolve()’:
callDppsvx.cpp:13:115: error: cannot convert ‘const char*’ to ‘const int*’ for argument ‘1’ to ‘void dppsvx_(const int*, const char*, const int*, const int*, double*, double*, char*, double*, double*, const int*, double*, const int*, double*, double*, double*, double*, int*, int*)’
make: *** [callDppsvx.o] Error 1