Eric Blake wrote:
> @@ -683,7 +684,9 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt
> LOCALE_PARAM)
> ++rp;
> if (*rp != '+' && *rp != '-')
> return NULL;
> +#if defined _LIBC || HAVE_TM_GMTOFF
> neg = *rp++ == '-';
> +#endif
> n = 0;
> while (n < 4 && *rp >= '0' && *rp <= '9')
> {
Here you need to pull the side effect of the statement outside the #if.
gcc would have done this optimization correctly. If you do it by hand,
you have a risk of introducing bugs. That's why -Wunused-but-set-variable
is not a good warning to enable all the time: It's the compiler's job
to eliminate unused variables.
I don't want a compiler that warns about each and every optimization it
performs, because such pickiness means that I have to write code at a
lower level, with more manual micro-optimizations, than I really want to.
Imagine if gcc had a warning to signal that a loop is only performed once
(and thus the 'for/do/while' around it is not needed). It would make it
impossible to use the do { ... } while (0) idiom.
Bruno