From mboxrd@z Thu Jan 1 00:00:00 1970 From: Veksler Michael To: help-gcc@gnu.org Subject: Re: Over optimisation Date: Sun, 31 Oct 1999 13:57:00 -0000 Message-ID: <7t80u4$5mk$1@techftp.technion.ac.il> References: <01bf05ce$5ca544c0$4f7fa890@us1.lincoln.msl.mitel.com> X-SW-Source: 1999-10n/msg00036.html Message-ID: <19991031135700.O7Oy_AiEUyPw43yzNxkSmwoI89otkOoXAtRT7-G1xZs@z> Andrew Davies wrote: > Hi, > I have a problem with the optimiser. When I compile the following test > loop: > > do { > test = regbase->utx & 0x8000; > }while(test == 0x0000); [snip] > I think the optimiser is assuming the line inside the do while loop is > static and therefore removes it from the loop. As a result it gets stuck. > Anyone know how to solve this without turning the optimiser off? The optimizer is right, unless you declare regbase volatile. Otherwise, the compiler has a right to assume that no one is modifying 'regbase'. Michael