This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: Strange shifting behaviour


Would the warning generated not suffice?  

corey

On 7/13/05, John Yates <jyates@netezza.com> 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@adobe.com]
> Sent: Tuesday, July 12, 2005 6:46 PM
> To: Ulf Magnusson; gcc-help@gcc.gnu.org
> 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
> 
>


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