From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8343 invoked by alias); 10 Mar 2009 14:36:31 -0000 Received: (qmail 8332 invoked by uid 22791); 10 Mar 2009 14:36:29 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-ew0-f160.google.com (HELO mail-ew0-f160.google.com) (209.85.219.160) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 Mar 2009 14:36:16 +0000 Received: by ewy4 with SMTP id 4so1248197ewy.8 for ; Tue, 10 Mar 2009 07:36:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.11.67 with SMTP id 45mr2760011wew.53.1236695773800; Tue, 10 Mar 2009 07:36:13 -0700 (PDT) In-Reply-To: <21fb03090903100718p5124233cn59452c54477fb1a1@mail.gmail.com> References: <21fb03090903100718p5124233cn59452c54477fb1a1@mail.gmail.com> Date: Tue, 10 Mar 2009 14:36:00 -0000 Message-ID: <6c33472e0903100736x3fca5930m67c7d1d2248c0f24@mail.gmail.com> Subject: Re: Implicit conversion from 32bits integer to 16bits integer (GCC 4.3.3) From: =?ISO-8859-1?Q?Manuel_L=F3pez=2DIb=E1=F1ez?= To: Frederic Belouin Cc: gcc-help@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2009-03/txt/msg00103.txt.bz2 2009/3/10 Frederic Belouin : > Hello, > > I would like to have a warning when there is an Implicit conversion in > source code: This is a question for gcc-help. > uint32_t foo =3D 2000; > > uint16_t bar =3D foo;=A0 //--> Warning Implicit conversion from uint32_t > to uint16_t.... > > uint16_t bar2=3D (uint16_t) foo; // --> no warning. > > > I now that -Wtraditional-conversion in GCC 4.3.x is able to show this > message, It should not. Does it really? Can you provide a complete preprocessed test= case? > but it also display warning for function implicit conversion: > Is it possible to have only warning for implicit conversion for > variable and not for prototype? You did not understand what -Wtraditional-conversion does: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html -Wtraditional-conversion (C and Objective-C only) Warn if a prototype causes a type conversion that is different from what would happen to the same argument in the absence of a prototype. It means that, if there was no prototype for foobar, there would be a type conversion different from what occurs given the prototype, and that is what Wtraditional-conversion warns. What you want is -Wconversion. http://gcc.gnu.org/wiki/NewWconversion Cheers, Manuel.