Trying to eliminate optimizations on some functions with VC++

Lee Salzman lsalzman1 at cox.net
Sun Aug 8 16:24:04 PDT 2004


If you would like to confirm if this is a compiler bug, try the
following program with global optimizations turned on:

#include <stdlib.h>
#include <stdio.h>
int main (int argc, char ** argv) {
  printf ("%d\n", (int) strtoul (argv [1], NULL, 10) >> 1);
  return EXIT_SUCCESS;
}

Run this program with -1 as input. The correct output should be -1 in
this case. If it is a positive number, then VC has a serious bug.

On Mon, Aug 09, 2004 at 12:46:54AM +0200, Jaco van der Merwe wrote:
> 
> I also tested with the global optimization switched off around this function
> and then the release build works for VC++.
> 
> However, I view this as a workaround. We need to find the reason why this
> happens.
> 
> Is it a compiler bug or is it something in the VM code that becomes
> susceptable to this problem with optimizations? If it is the latter it needs
> to be corrected so that the same won't happen with other compilers either.
> 
> Jaco
> 
> ----- Original Message ----- 
> From: "Paul Dufresne" <dufrp at hotmail.com>
> To: <slate at tunes.org>
> Sent: Sunday, August 08, 2004 11:06 PM
> Subject: RE: Trying to eliminate optimizations on some functions with VC++
> 
> 
> > I tried the parenthesis:
> > #pragma optimize("g", off)
> > static INLINE signed long int ObjectPointer_asSmallInt(ObjectPointer oop)
> > {
> >   return ((signed long int) oop) >> 1;
> > }
> > #pragma optimize("g", on)
> >
> > But if I remove the #pragmas, this give unhandled exception.
> >




More information about the Slate mailing list