Hello,
Looks like this is happening due to positioning return 0; Move this to
the end of the main and the code is generated correctly!!!
In the current scenario the jump to instead of moving to return 0 is
jumping to the line immediately after return 0!!!
Interesting problem though.
Regards,
Kiran
Wipro Technologies,
26 Hosur Main Road,
Bommanahalli,
Bangalore - 560068
Phone : 41371000 ext 5291
VOIP : 803-4049
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Raja Reddy
Sent: Thursday, May 17, 2007 10:14 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Strange problem with VC++ compiler because of goto
Hello,
Today I found a serious problem in the following code when I compiled
with VC++ 6.
The installed compiler & linker versions are 12.00.8804, 6.00.8447 on
x86 system respectively.
#include <stdio.h>
int alloc()
{
return 0;
}
int main(int argc, char* argv)
{
printf(“Testing!\n”);
if(alloc() == 0)
goto Radhe;
return 0;
Radhe:
printf(“Hello\n”);
}
I expected that “Hello” will be printed just once because, the if
statement jumps the instruction pointer to the label.
But “Hello” is priting always till I kill the process.
When I check the assembly code, I found a JMP instruction right after
printf(“Hello\n”) line, instead of a RET instruction.
I don’t know whether this is known bug in VC compilers or microsoft
standard. I just want to share this with all of experts here.
If this is the wrong place to post, please ignore.
Regards,
Raja Reddy.
________________________________
Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.
http:ylc=X3oDMTE5cDF2bXZzBF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDZ3JlZW4tY2Vu
dGVy> — Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the
List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer</http:></stdio.h>