V
V.Subramanian, India
Consider the following program no_warning.c :
#include <stdlib.h>
#include <stdio.h>
int main()
{
size_t length = 4294967295U;
int size = 4294967295U;
size = length;
return EXIT_SUCCESS;
}
When I compile this program with
gcc (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.1)
as
gcc -std=c99 -pedantic -Wall -Wextra no_warning.c
it did not generate any warning.
Consider the statements:
int size = 4294967295U;
size = length;
In both these statements, I am assigning 'unsigned int' to 'plain
int'. Still the compiler accepts them without issuing any warnings. I
am unable to understand this.
Please explain.
Thanks
V.Subramanian
#include <stdlib.h>
#include <stdio.h>
int main()
{
size_t length = 4294967295U;
int size = 4294967295U;
size = length;
return EXIT_SUCCESS;
}
When I compile this program with
gcc (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.1)
as
gcc -std=c99 -pedantic -Wall -Wextra no_warning.c
it did not generate any warning.
Consider the statements:
int size = 4294967295U;
size = length;
In both these statements, I am assigning 'unsigned int' to 'plain
int'. Still the compiler accepts them without issuing any warnings. I
am unable to understand this.
Please explain.
Thanks
V.Subramanian