It depends on whether you want acknowledge the impression that your compiler makes on users who are not language lawyers. Now that gcc has adopted SSA and implemented the Wegman- Zadeck ConditionalConst scheme for partial evaluation I believe (in fact I know from having implemented that same algorithm over ten year ago [1]) that the compiler will be evaluating expressions at compile time that are not identified as CTCEs by the language standard. Are you going to issue a warning on every shift operation for which you cannot prove that the shift count is within the "defined behavior" range? It just makes a poor impression to say "the compiler is inconsistent in how it evaluates a given expression because the language standard allows it to be". This is even harder to justify when the fix does not degrade the quality of generated code but rather requires the compile-time simulation of run-time computation to be more faithful. /john [1] http://gcc.gnu.org/wiki/JohnYates -----Original Message----- From: corey taylor [mailto:corey.taylor@xxxxxxxxx] Sent: Wednesday, July 13, 2005 2:19 PM To: John Yates Cc: Eljay Love-Jensen; Ulf Magnusson; gcc-help@xxxxxxxxxxx Subject: Re: Strange shifting behaviour Would the warning generated not suffice? corey On 7/13/05, John Yates <jyates@xxxxxxxxxxx> wrote: > Eljay, > > Though I agree with your point about the standards and > undefined behavior, I do believe that Ulf has identified > a quality of implementation issue. > > Would you not agree that compile-time expression evaluation > should mimic run-time as much as possible? Or to put it > another way, the more often compile-time and run-time > evaluated results diverge, the lower the subject quality > of the compiler. > > If the shift operator at run-time examines only the lower > order 5 bits of the shift count (as Ulf's x86 does) then > a "high-quality" compile-time expression evaluator ought > to do the same. > > /john > > -----Original Message----- > From: Eljay Love-Jensen [mailto:eljay@xxxxxxxxx] > Sent: Tuesday, July 12, 2005 6:46 PM > To: Ulf Magnusson; gcc-help@xxxxxxxxxxx > Subject: Re: Strange shifting behaviour > > > Hi Ulf, > > >When shifting an int by its size in bits... > > That is undefined behavior (implementation dependent), as per C and C++ standards. Ever since C was first taking it's first baby steps. > > By "undefined behavior", that means any given particular implementation can: > + not do anything > + do what you expect > + SEGV > + format your hard drive > > --Eljay > >