Bugzilla – Bug 137124
xosview-1.8.2-5: undefined C code
Last modified: 2005-12-13 12:24:17 UTC
I just tried to compile package xosview-1.8.2-5 with a prerelease of the GNU C compiler version 4.1. It said Xrm.cc:101: warning: operation on "p" may be undefined The source code is while (p && *p) *p++ = tolower(*p); I agree with the compiler - this code seems to be undefined. Suggest new code while (p && *p) { *p = tolower(*p); ++p; } BTW, the email address of the author seems to be broken [ romberg@md.fsl.noaa.gov ]
Please explain the difference between *p = tolower(*p); ++p; and *p++ = tolower(*p); ... IMO the `++' is only applied after the value of the current p is changed. And AFAIK the left side of the asignment is executed before.
>Please explain the difference between This is a FAQ for C, but I'll have a go anyway There are no guarantees in C that the left side of an assignment is evaluated before or after the right side. The ++ of p on the left side could happen at any time after the value of p is read for the left side. This is independent of the read of p on the right side. More detail is provided in K&R C [ the white book ] or Steve Summit's FAQ for C. Even more detail is provided by doing a web search for "sequence points" in ISO C standards documents and the like. I am happy to answer any further questions.
Fixed for next release