Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #11588

Re: no warning for assigning unsigned int to plain int

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: no warning for assigning unsigned int to plain int
Date 2011-10-12 12:17 -0400
Organization A noiseless patient Spider
Message-ID <4E95BD7E.5000502@verizon.net> (permalink)
References <4075cf5b-5ede-472b-8a8f-aaeca4205c8d@l39g2000pro.googlegroups.com>

Show all headers | View raw


On 10/12/2011 10:36 AM, V.Subramanian, India 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.

6.5.16.1p1 requires that:
> One of the following shall hold:96)
> — the left operand has qualified or unqualified arithmetic type and the right has arithmetic type;

size_t and int are both arithmetic types, so that requirement has been
met. There's no other relevant constraint on the types, so no diagnostic
is required. An implementation is allowed to complain about anything it
wants, but there's no requirement that it complain about this. Why did
you think that there was?

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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