[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

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.