This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: BUG: erroneous read access to volatile mem ref


----- Original Message ----- 
From: Graham Stott <grahams@cygnus.co.uk>

> Well there is a work around for both the C++ and C testcases
> cast to void the result of the assignments to volatile variables.
> 
> For your C++ example
> 
> inline void Watchdog()
> {
>     (void)(TCW = 0);
> }

Great! Thank you.

(It looks a bit sick, though ;-)

> Well it's likely it goes back to the beginning of time when statement
> expressions were first implemented cira. late 1980's? 

It seems that this has not been a problem until the introduction
of the new inliner. In desktop applications this behaviour should
never be a problem. But in hardware-related applications this is
not acceptable.
Imagine a memory-mapped output port with "LATCH ENABLE" directly
connected to a chip select (and read/write lines not decoded).
That kind of peripheral (which is not too rare..) would work
as long as there are only writes. Otherwise the output pins would
be undefined.

> 
> > But even if this issue is that old, I keep calling it a BUG.
> > At least in the "inline" case noone would expect that kind
> > of side effect.

I stick to that.


Ralf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]