This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Strange shifting behaviour
- From: corey taylor <corey dot taylor at gmail dot com>
- To: John Yates <jyates at netezza dot com>
- Cc: Eljay Love-Jensen <eljay at adobe dot com>, Ulf Magnusson <ulfalizer at gmail dot com>, gcc-help at gcc dot gnu dot org
- Date: Wed, 13 Jul 2005 13:19:09 -0500
- Subject: Re: Strange shifting behaviour
- References: <F0CD2E5262214F44959AD6AF34ADA66E01D13105@mail2.netezza.com>
- Reply-to: corey taylor <corey dot taylor at gmail dot com>
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
>
>