Repository navigation
Description
Translating Lapack 3.8.0 with a recent gfortran using lto, I get a few lto type
mismatches (i.e. the subroutine is called with different arguments than the
ones it is declared with).
cerrst.f:635: Warnung: Typ von »cheevx_2stage« passt nicht zur ursprünglichen Deklaration [-Wlto-type-mismatch]
635 | $ M, X, Z, 1, W, 1, RW, IW, I3, INFO )
|
cheevx_2stage.f:305: Anmerkung: »cheevx_2stage« wurde vorher hier deklariert
cheevx_2stage.f:305: Anmerkung: code may be misoptimized unless »-fno-strict-aliasing« is used
cerrst.f:1266: Warnung: Typ von »chbevx_2stage« passt nicht zur ursprünglichen Deklaration [-Wlto-type-mismatch]
1266 | $ M, X, Z, 1, W, 0, RW, IW, I3, INFO )
|
chbevx_2stage.f:325: Anmerkung: »chbevx_2stage« wurde vorher hier deklariert
chbevx_2stage.f:325: Anmerkung: code may be misoptimized unless »-fno-strict-aliasing« is used
cerrst.f:763: Warnung: Typ von »cheevr_2stage« passt nicht zur ursprünglichen Deklaration [-Wlto-type-mismatch]
763 | $ 10*N, INFO )
|
cheevr_2stage.f:404: Anmerkung: »cheevr_2stage« wurde vorher hier deklariert
cheevr_2stage.f:404: Anmerkung: code may be misoptimized unless »-fno-strict-aliasing« is used
cchkst2stg.f:1017: Warnung: Typ von »dlaset« passt nicht zur ursprünglichen Deklaration [-Wlto-type-mismatch]
1017 | CALL DLASET( 'Full', N, 1, ZERO, ZERO, SD, 1 )
|
dlaset.f:111: Anmerkung: »dlaset« wurde vorher hier deklariert
[...]
zdrvls.f:567: Warnung: Typ von »zscal« passt nicht zur ursprünglichen Deklaration [-Wlto-type-mismatch]
567 | $ 1 )
|
zscal.f:79: Anmerkung: »zscal« wurde vorher hier deklariert
zscal.f:79: Anmerkung: code may be misoptimized unless »-fno-strict-aliasing« is used
ztsqr01.f:224: Warnung: Typ von »zlansy« passt nicht zur ursprünglichen Deklaration [-Wlto-type-mismatch]
224 | RESID = ZLANSY( '1', 'Upper', M, R, M, RWORK )
|
zlansy.f:124: Anmerkung: »zlansy« wurde vorher hier deklariert
zlansy.f:124: Anmerkung: code may be misoptimized unless »-fno-strict-aliasing« is used
zchkhe_aa_2stage.f:540: Warnung: Typ von »zpot02« passt nicht zur ursprünglichen Deklaration [-Wlto-type-mismatch]
540 | $ WORK, LDA, RWORK, RESULT( 2 ) )
|
zpot02.f:127: Anmerkung: »zpot02« wurde vorher hier deklariert
127 | SUBROUTINE ZPOT02( UPLO, N, NRHS, A, LDA, X, LDX, B, LDB, RWORK,
|
zpot02.f:127: Anmerkung: code may be misoptimized unless »-fno-strict-aliasing« is used
zchkhe_aa_2stage.f:324: Warnung: Typ von »zlatms« passt nicht zur ursprünglichen Deklaration [-Wlto-type-mismatch]
324 | $ INFO )
|
zlatms.f:332: Anmerkung: »zlatms« wurde vorher hier deklariert
zlatms.f:332: Anmerkung: code may be misoptimized unless »-fno-strict-aliasing« is used
ztsqr01.f:212: Warnung: Typ von »zlange« passt nicht zur ursprünglichen Deklaration [-Wlto-type-mismatch]
212 | ANORM = ZLANGE( '1', M, N, A, M, RWORK )
|
zlange.f:116: Anmerkung: »zlange« wurde vorher hier deklariert
zlange.f:116: Anmerkung: code may be misoptimized unless »-fno-strict-aliasing« is used
zchkaa.f:745: Warnung: Typ von »zchkhe_aa_2stage« passt nicht zur ursprünglichen Deklaration [-Wlto-type-mismatch]
745 | $ WORK, RWORK, IWORK, NOUT )
|
zchkhe_aa_2stage.f:171: Anmerkung: »zchkhe_aa_2stage« wurde vorher hier deklariert
171 | SUBROUTINE ZCHKHE_AA_2STAGE( DOTYPE, NN, NVAL, NNB, NBVAL, NNS,
|
zchkhe_aa_2stage.f:171: Anmerkung: code may be misoptimized unless »-fno-strict-aliasing« is used
Activity
Dichloromethane commentedon Apr 19, 2019
An example of what is wrong: In cerrst.f, there is
and in cheev_2stage.f,
There is a mismatch in the third argument, where a character 'U' is passed to an
integer argument, N.
[Edit: I looked at the wrong routine here.]
langou commentedon Apr 19, 2019
Hi @Dichloromethane
Be careful between CHEEV_2STAGE and CHEEVX_2STAGE. This is not the same interface. I did not have time to review too much. I wanted to point this out. CHEEVX_2STAGE has RANGE in between JOBZ and UPLO in the interface.
Your help in fixing this issue is much appreciated!
Julien.
Dichloromethane commentedon Apr 20, 2019
OK, let's try to get this correct this time :-)
The caller has
and the callee has
C...
REAL ABSTOL, VL, VU
The seventh and eight arguments (VL and VU) are declared as REAL dummy arguments,
but the actual arguments passed are 0.0D0 (double). This "works" for IEEE, because of
the bit pattern of all zeros for both single and double zero.
DLASET is called from cchkst2stg.f with
with
and has
so a REAL is passed to a DOUBLE precision argument. Apart from being a standard
violation, this can easily lead into trouble because (putting on my implementer's hat
here) the argument is passed via a pointer, and a pointer to a REAL points to a
memory location which is only guaranteed to hold four bytes of null bytes, and the
rest of the memory, which is accessed as a double, can contain garbage. The
pointer can also be misaligned on targets which require eight-byte alignment for
DOUBLE precision.
zscal is a BLAS routine which has
which is called from zdrvls.f with
in effect passing a double precision value to a complex dummy argument.
This effectively randomizes the real part; again, the code depends on luck
to do anything useful.
I suspect the other cases are similar - just looking at the definition should be
enough.
(This makes me wonder a bit why Lapack is stuck with FORTRAN 77 - style
argument lists. Fortran 90+ compilers have been around for some time, and
putting these routines in modules would have caught all these errors).
Dichloromethane commentedon Apr 20, 2019
The ZLANSY / ZTSQR01 issue looks like a compiler bug: If I remember correctly,
it is legal to pass a complex array to a real dummy argument, if it is done F77-style.
I'll dig through the standard and open a gfortran PR for this, it it applies.
[Edit] This is not a compiler bug, this is indeed illegal code (see below).
Dichloromethane commentedon Apr 20, 2019
zpot02 vs. zchkhe_aa_2stage is also a double complex variable being passed to
a double precision work array. Again, this should not be flagged (but it would be
trivial to shut up the warning).
Dichloromethane commentedon Apr 20, 2019
Same thing with the complex/ real work arrays for zlange being called by ztsqr01 and
zchkaa calling zchkhe_aa_2stage.
Looking at the F2018 standard again, it seems that the code is illegal after all.
15.5.2.4 Ordinary dummy variables
1 The requirements in this subclause apply to actual arguments that correspond to nonallocatable nonpointer dummy data objects. [which is the case here].
2 The dummy argument shall be type compatible with the actual argument.
and 7.3.2.3 has
5 A nonpolymorphic entity is type compatible only with entities of the same declared type.
So, all the cases flagged in this report are indeed errors. No need to submit a PR, then.