I have compiled following program using gcc prog.c -Wall -Wextra -std=gnu11 -pedantic
command on GCC compiler. I wondered, it is working fine without any warnings or errors.
#include <stdio.h>
int main(void)
{
for (int i = 0; i == 0; i++)
{
printf("%d\n", i);
long int i = 1; // Why doesn't redeclaration error?
printf("%ld\n", i);
}
}
Why compiler doesn't generate redeclaration variable i
error?
Best Answer
From standard ยง6.8.5.5 (N1570)
Emphasis added