From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19898 invoked by alias); 17 Oct 2007 11:48:04 -0000 Received: (qmail 19887 invoked by uid 22791); 17 Oct 2007 11:48:02 -0000 X-Spam-Check-By: sourceware.org Received: from mail5.primus.ca (HELO mail-08.primus.ca) (216.254.141.172) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 17 Oct 2007 11:48:00 +0000 Received: from ottawa-hs-209-217-122-41.s-ip.magma.ca ([209.217.122.41] helo=[192.168.8.125]) by mail-08.primus.ca with esmtpa (Exim 4.63) (envelope-from ) id 1Ii7NW-0007Xw-1h; Wed, 17 Oct 2007 07:47:58 -0400 Message-ID: <4715F65A.20106@ellipticsemi.com> Date: Wed, 17 Oct 2007 11:49:00 -0000 From: Tom St Denis User-Agent: Thunderbird 1.5.0.13 (X11/20070824) MIME-Version: 1.0 To: "Humpolicek, Jiri - Acision" CC: gcc-help@gcc.gnu.org Subject: Re: gcc warnings References: <53248A54C3B3EC4EAAD993D10A6DD01203C5DAB7@cz-ex002.groupinfra.com> In-Reply-To: <53248A54C3B3EC4EAAD993D10A6DD01203C5DAB7@cz-ex002.groupinfra.com> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated: elp125 - ottawa-hs-209-217-122-41.s-ip.magma.ca ([192.168.8.125]) [209.217.122.41] X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2007-10/txt/msg00210.txt.bz2 Humpolicek, Jiri - Acision wrote: > Hi, > I have, from my point of view, strange problem. I want to tell gcc to report all compilation warnings, especially warnings about assigment from variable of greater type to variable with smaller type. For example, when I write following code and compile it with next command no warning is reported: > > c++ -o test test.cpp -Wall -Wextra -Wconversion -pedantic > > #include "stdio.h" > > int main() > { > long a = 10000; > unsigned char b = a; > > printf("%d\n", b); > > return b; > } > > The problem is that's not an error or problem as far as the C standard [and C++] goes. So a warning for that while valid, would probably be out of line. My recommendation is to simply not assign across types unless you have to. If you have a function like void myfunc(unsigned long somevalue) { } Then never store somevalue in anything but an unsigned long unless you're sure of what you are doing. Why would you write char careless = somevalue; just for the hell of it? Tom