gcc bug? (was bug in gen5200/tod/pcf8563.c)

Ingolf Steinbach ingolf.steinbach at googlemail.com
Tue May 15 12:48:42 UTC 2007

2007/5/15, Wolfram Wadepohl <Wolfram.Wadepohl at ek-automation.com>:
>              |    v1 = info[PCF8563_DAY_ADR-PCF8563_SECOND_ADR] &
>           175|    time->day = From_BCD(v1);

How exactly is info declared. If it is meant to be a pointer to some
hardware register, it should be volatile qualified (e.g. "uint32_t
volatile* info").

If it is not qualified, an optimizing compiler might (IMO correctly)
deduce that it is not necessary to place the value read from
info[....] in the v1 variable if there is no function call between the
assignment v1 = .... and the expanded From_BCD() macro. The compiler
might decide that it is equivalent read the value at info[....] twice
in the macro expansion thus leading to two different _x values.

More information about the users mailing list