Trying to eliminate optimizations on some functions with VC++
Paul Dufresne
dufrp at hotmail.com
Sun Aug 8 17:27:20 PDT 2004
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
_________________________________________________________________
Balayez vos courriels entrants et sortants et les pièces jointes et
contribuez à éliminer les virus destructeurs susceptibles dy être intégrés.
http://join.msn.com/?pgmarket=fr-ca&page=features/virus Commencez dès
maintenant à profiter de tous les avantages de MSN Premium et obtenez les
deux premiers mois GRATUITS*.
More information about the Slate
mailing list