[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
20000926: xsatim.c compiler warning
- Subject: 20000926: xsatim.c compiler warning
- Date: Tue, 26 Sep 2000 15:18:23 -0600
Scott and Steve,
The OSF/1 C compiler provides the following warning message when compiling
$GEMPAK/source/driver/active/xw/xsatim.c:
cc: Warning: xsatim.c, line 414: In this statement, the expression
"*imgptr++=*(imgptr-xwdth)"
modifies "imgptr", and fetches its value in a computation that is not used
to produce the modified value without an intervening sequence point.
This behavior is undefined. (undefvarfetch)
*imgptr++ = *(imgptr - xwdth);
I can't attribute any problems to this message, however, the code may be
brittle on some other compilers with optimization flags.
This made me go back to some conversations I had with Steve Drake and Dave
Himes at COMET a while back regarding some HPUX problems in a similar routine.
Dave Himes had suggested as an alternative to:
else if ( (row != 0) && (rowtrans[row] == rowtrans[row -1]) ){
/*
* replicate line
*/
for ( col = 0; col < xwdth; col++) {
*imgptr++ = *(imgptr - xwdth);
}
continue; /* finish the row */
}
Use memcpy:
else if ( (row != 0) && (rowtrans[row] == rowtrans[row -1]) ){
/*
* replicate line
*/
memcpy(imgptr, imgptr - xwdth, xwdth);
imgptr += xwdth;
continue; /* next row */
}
Steve Chiswell
Unidata User Support