There are many places where the f90 code uses uninitialized variables.
The attached md file shows the ones I've found and hopefully fixed,
although there may be more elegant fixes.
These bugs were found using the gcc/gfortran "undefined behavior sanitizer
(ubsan)" analyzer at run time. Consequently, it will only report problems
in code that is executed by whatever set of random buttons in the GUI I hit.
I would expect that more bugs of this sort will be found by the compiler at
compile time, especially if you compile with -O3 optim level.
See attachment
# bug: Fortran uses uninitialized variables
```
diff --git a/lib/sh65.f90 b/lib/sh65.f90
index 09bef9c24..2014f60fc 100644
--- a/lib/sh65.f90
+++ b/lib/sh65.f90
@@ -8,6 +8,8 @@ subroutine sh65(cx,n5,mode65,ntol,xdf,nspecial,snrdb)
integer ipk(16)
ss=0.
+ snr1 = 0.
+ snr2 = 0
jstep=NFFT/8
nblks=272
```
```
diff --git a/lib/qra/q65/q65code.f90 b/lib/qra/q65/q65code.f90
index d61cba916..0111a4814 100644
--- a/lib/qra/q65/q65code.f90
+++ b/lib/qra/q65/q65code.f90
@@ -5,6 +5,7 @@ program q65code
character*37 msg37
integer nargs
integer codeword(65),tones(85)
+ integer iargc
nargs=iargc()
if(nargs .ne. 1) then
```
diff --git a/lib/qra/q65/q65.f90 b/lib/qra/q65/q65.f90
index f93fca509..7df59ce1b 100644
--- a/lib/qra/q65/q65.f90
+++ b/lib/qra/q65/q65.f90
@@ -530,7 +530,7 @@ subroutine q65_ccf_22(s1,iz,jz,nfqso,ntol,iavg,ipk,jpk, &
if(ccfmax.gt.ccfbest .and. abs(i*df-nfqso).le.ftol) then
ccfbest=ccfmax
- snrbest=snr
+ ! snrbest=snr ! snrbest not used. snr may be uninitialized
ibest=i
lagbest=lagpk
idrift_best=idrift_max
```
```
diff --git a/lib/ft8_decode.f90 b/lib/ft8_decode.f90
index 9b87114e5..e1836aef3 100644
--- a/lib/ft8_decode.f90
+++ b/lib/ft8_decode.f90
@@ -65,11 +65,14 @@ contains
integer itone_save(NN,MAX_EARLY)
real f1_save(MAX_EARLY)
real xdt_save(MAX_EARLY)
+ integer*4 n2
+
data nutc0/-1/
save dd,dd1,nutc0,ndec_early,itone_save,f1_save,xdt_save,lsubtracted, &
allmessages
+ n2 = 0
this%callback => callback
write(datetime,1001) nutc !### TEMPORARY ###
1001 format("000000_",i6.6)
```
```
diff --git a/lib/ft4_decode.f90 b/lib/ft4_decode.f90
index b15368a4b..38790c1b3 100644
--- a/lib/ft4_decode.f90
+++ b/lib/ft4_decode.f90
@@ -70,6 +70,7 @@ contains
logical badsync
logical, intent(in) :: lapcqonly
+ data cdatetime0/' '/
data first/.true./
data mcq/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0/
data mcqru/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,0,0,1,1,0,0/
```
```
diff --git a/lib/fst4/ldpcsim240_74.f90 b/lib/fst4/ldpcsim240_74.f90
index d6838607d..78c9cef13 100644
--- a/lib/fst4/ldpcsim240_74.f90
+++ b/lib/fst4/ldpcsim240_74.f90
@@ -105,6 +105,7 @@ program ldpcsim240_74
enddo
enddo
+ iq = 1 ! initial guess at bits per symbol, possibly changes in loop
write(*,*) "Eb/N0 Es/N0 ngood nundetected symbol error rate"
do idb = 24,-8,-1
db=idb/2.0-1.0
```
```
diff --git a/lib/fst4/fastosd240_74.f90 b/lib/fst4/fastosd240_74.f90
index 3e812e0f8..679372db2 100644
--- a/lib/fst4/fastosd240_74.f90
+++ b/lib/fst4/fastosd240_74.f90
@@ -165,6 +165,7 @@ subroutine fastosd240_74(llr,k,apmask,ndeep,message74,cw,nhardmin,dmin)
ntotal=0
nrejected=0
xlambda=0.0
+ nsyndmax=0
if(ndeep.eq.0) goto 998 ! norder=0
if(ndeep.gt.4) ndeep=4
```
_______________________________________________
wsjt-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wsjt-devel