>but is it part of the C standard or the C++ standard?
I'm not sure about the C++ standard, but I'm quite sure about C89 and most likely C99 as well. I would have to assume that it is supported in C++ for compatibility with C though.
>print out a dissassembly and post it?
Gladly, I had to modify the program so that it would actually compile, so the disassembly of the following code:
Code:
#include <stdio.h>
int main ( void )
{
int a = 2;
{
int a = 0;
a++;
}
printf ( "%d\n", a );
return 0;
}
Which gives me one warning in Lint:
Code:
cTest.c: (in function main)
cTest.c(7,9): Variable a shadows outer declaration
An outer declaration is shadowed by the local declaration. (Use -shadow to
inhibit warning)
cTest.c(5,7): Previous definition of a: int
Is as follows for MSVC++ 6:
Code:
1: #include <stdio.h>
2:
3: int main ( void )
4: {
00401000 push ebp
00401001 mov ebp,esp
00401003 sub esp,48h
00401006 push ebx
00401007 push esi
00401008 push edi
00401009 lea edi,[ebp-48h]
0040100C mov ecx,12h
00401011 mov eax,0CCCCCCCCh
00401016 rep stos dword ptr [edi]
5: int a = 2;
00401018 mov dword ptr [ebp-4],2
6: {
7: int a = 0;
0040101F mov dword ptr [a],0
8: a++;
00401026 mov eax,dword ptr [a]
00401029 add eax,1
0040102C mov dword ptr [a],eax
9: }
10: printf ( "%d\n", a );
0040102F mov ecx,dword ptr [ebp-4]
00401032 push ecx
00401033 push offset string "%d\n" (0040c01c)
00401038 call printf (00401060)
0040103D add esp,8
11: return 0;
00401040 xor eax,eax
12: }
00401042 pop edi
00401043 pop esi
00401044 pop ebx
00401045 add esp,48h
00401048 cmp ebp,esp
0040104A call __chkesp (004010e0)
0040104F mov esp,ebp
00401051 pop ebp
00401052 ret
-Prelude