Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ike Naar <ike@sverige.freeshell.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: no warning for assigning unsigned int to plain int |
| Date | 2011-10-12 17:53 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrn3vfsj9bl0q.77u.ike@sverige.freeshell.org> (permalink) |
| References | <4075cf5b-5ede-472b-8a8f-aaeca4205c8d@l39g2000pro.googlegroups.com> |
On 2011-10-12, V.Subramanian, India <subramanian100in@yahoo.com> wrote:
> 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.
If you're using gcc, you can use the -Wconversion compiler option.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
no warning for assigning unsigned int to plain int "V.Subramanian, India" <subramanian100in@yahoo.com> - 2011-10-12 07:36 -0700
Re: no warning for assigning unsigned int to plain int James Kuyper <jameskuyper@verizon.net> - 2011-10-12 12:17 -0400
Re: no warning for assigning unsigned int to plain int Kleuskes & Moos <kleuske@somewhere.else.net> - 2011-10-12 17:28 +0000
Re: no warning for assigning unsigned int to plain int Keith Thompson <kst-u@mib.org> - 2011-10-12 12:36 -0700
Re: no warning for assigning unsigned int to plain int Ike Naar <ike@sverige.freeshell.org> - 2011-10-12 17:53 +0000
Re: no warning for assigning unsigned int to plain int Keith Thompson <kst-u@mib.org> - 2011-10-12 12:41 -0700
csiph-web