[R-pkg-devel] warning: type of ‘zhpevx_’ does not match original declaration [-Wlto-type-mismatch]
Pierre Lafaye de Micheaux
|@|@ye @end|ng |rom un@w@edu@@u
Tue Jul 7 01:38:57 CEST 2020
Hello Bill,
Thank you for your insight.
First, my impression, is that the problem comes from how I declare the type of the function itself (and not its parameters), since the first (and only warning they seen on the CRAN) message is:
<quote>
myzhpevx.cpp:13:16: warning: type of �zhpevx_� does not match original declaration [-Wlto-type-mismatch]
void F77_NAME(zhpevx)(char *jobz, char *range, char *uplo,
</quote>
What I did is the following:
<quote>
void F77_NAME(zhpevx)(char *jobz, char *range, char *uplo,
const int *n, Rcomplex *ap, const double *vl,
const double *vu, const int *il, const int *iu,
const double *abstol, int *m, double *w,
Rcomplex *z, const int *ldz, Rcomplex *work, double *rwork,
int *iwork, int *ifail, int *info,
FC_LEN_T jobz_len, FC_LEN_T range_len, FC_LEN_T uplo_len);
char cjobz[2];
strncpy(cjobz, jobz[0], 1);
cjobz[1] = '\0';
char crange[2];
strncpy(crange, range[0], 1);
crange[1] = '\0';
char cuplo[2];
strncpy(cuplo, uplo[0], 1);
cuplo[1] = '\0';
F77_CALL(zhpevx)(cjobz, crange, cuplo, &n[0], ap, &vl[0], &vu[0], &il[0], &iu[0], &abstol[0], &m[0],
w, z, &ldz[0], work, rwork, iwork, ifail, &info[0], strlen(cjobz), strlen(crange), strlen(cuplo));
</quote>
Do you see anything wrong with the above?
Thank you
Best
Pierre
________________________________
From: William Dunlap <wdunlap using tibco.com>
Sent: Tuesday, 7 July 2020 08:36
To: Pierre Lafaye de Micheaux <lafaye using unsw.edu.au>
Cc: Ivan Krylov <krylov.r00t using gmail.com>; r-package-devel using r-project.org <r-package-devel using r-project.org>
Subject: Re: [R-pkg-devel] warning: type of �zhpevx_� does not match original declaration [-Wlto-type-mismatch]
Have you tried what is recommended in
https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html
?
<quote>
For arguments of CHARACTER type, the character length is passed as a
hidden argument at the end of the argument list. For deferred-length
strings, the value is passed by reference, otherwise by value. The
character length has the C type size_t (or INTEGER(kind=C_SIZE_T) in
Fortran). Note that this is different to older versions of the GNU
Fortran compiler, where the type of the hidden character length
argument was a C int. In order to retain compatibility with older
versions, one can e.g. for the following Fortran procedure
subroutine fstrlen (s, a)
character(len=*) :: s
integer :: a
print*, len(s)
end subroutine fstrlen
define the corresponding C prototype as follows:
#if __GNUC__ > 7
typedef size_t fortran_charlen_t;
#else
typedef int fortran_charlen_t;
#endif
void fstrlen_ (char*, int*, fortran_charlen_t);
In order to avoid such compiler-specific details, for new code it is
instead recommended to use the ISO_C_BINDING feature.
Note with C binding, CHARACTER(len=1) result variables are returned
according to the platform ABI and no hidden length argument is used
for dummy arguments; with VALUE, those variables are passed by value.
</quote>
Bill Dunlap
TIBCO Software
wdunlap tibco.com
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Jul 6, 2020 at 3:13 PM Pierre Lafaye de Micheaux
<lafaye using unsw.edu.au> wrote:
>
> Dear Ivan,
>
> Thank you very much for your response.
>
> I do not have more information than the one I gave in my previous email. (And on top of that, the computer I was using with Debian SID, a recent version of gfortran and the last version of R-devel, just broke.)
>
> My problem is that the CRAN team won't accept to publish my package until this WARNING problem is solved. And because I am unable to observe the warning on my side (I could not with the desktop that just broke, and I still can't with my current laptop with Debian 10), I have no clue on how to suppress this warning.
>
> Thank you in advance for any other advice.
>
> Best regards,
> Pierre
> ________________________________
> From: Ivan Krylov <krylov.r00t using gmail.com>
> Sent: Tuesday, 7 July 2020 06:11
> To: Pierre Lafaye de Micheaux <lafaye using unsw.edu.au>
> Cc: r-package-devel using r-project.org <r-package-devel using r-project.org>
> Subject: Re: [R-pkg-devel] warning: type of �zhpevx_� does not match original declaration [-Wlto-type-mismatch]
>
> On Fri, 3 Jul 2020 00:15:27 +0000
> Pierre Lafaye de Micheaux <lafaye using unsw.edu.au> wrote:
>
> >Found the following significant warnings:
> > myzhpevx.cpp:13:23: warning: type of _zhpevx__ does not match
> > original declaration [-Wlto-type-mismatch]
>
> I managed to reproduce the warning on R-devel r78607 built with
> --enable-lto using gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1):
>
> myzhpevx.cpp:13:16: warning: type of �zhpevx_� does not match original declaration [-Wlto-type-mismatch]
> void F77_NAME(zhpevx)(char *jobz, char *range, char *uplo,
> ^
> zhpevx.f:232:7: note: type mismatch in parameter 20
> SUBROUTINE zhpevx( JOBZ, RANGE, UPLO, N, AP, VL, VU, IL, IU,
> ^
> zhpevx.f:232:7: note: type �int� should match type �size_t�
> /usr/lib/gcc/x86_64-linux-gnu/6/include/stddef.h:216:23: note: the incompatible type is defined here
> typedef __SIZE_TYPE__ size_t;
> ^
> zhpevx.f:232:7: note: �zhpevx� was previously declared here
> SUBROUTINE zhpevx( JOBZ, RANGE, UPLO, N, AP, VL, VU, IL, IU,
> ^
>
> Do you have access to the notes produced by the compiler in addition
> to the warnings? Do they spell the same difference?
>
> If yes, the warning is likely to be safe to ignore. m4/R.m4 notes that,
> while gfortran < 8 uses int instead of size_t for hidden size arguments,
> it doesn't make a practical difference.
>
> --
> Best regards,
> Ivan
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
[[alternative HTML version deleted]]
More information about the R-package-devel
mailing list