Trying to eliminate optimizations on some functions with VC++

Lee Salzman lsalzman1 at cox.net
Sun Aug 8 17:31:29 PDT 2004


Okay, so it may be a bug in context. Possibly one of the uses of
ObjectPointer_asSmallInt is getting optimized wrong or in a way that is
not quite friendly with the C standard. Any help finding out which use
it is?

Thanks,
Lee

On Mon, Aug 09, 2004 at 12:27:20AM +0000, Paul Dufresne wrote:
> Lee said to test:
> ===
> #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.
> ===
> 
> My result is:
> ===
> C:\testvc>cl /Ox test.c
> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
> Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
> 
> test.c
> Microsoft (R) Incremental Linker Version 7.10.3077
> Copyright (C) Microsoft Corporation.  All rights reserved.
> 
> /out:test.exe
> test.obj
> 
> C:\testvc>test -84
> -42
> 
> C:\testvc>test 12
> 6
> 
> C:\testvc>test -2
> -1
> 
> C:\testvc>test -1
> -1
> ===
> So the answer is not so obvious.
> 
> --Paul
> 




More information about the Slate mailing list