From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76439 invoked by alias); 8 Apr 2019 11:27:04 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 75738 invoked by uid 89); 8 Apr 2019 11:27:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=H*UA:https X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 08 Apr 2019 11:27:02 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B57E8AD73; Mon, 8 Apr 2019 11:27:00 +0000 (UTC) From: Martin Jambor To: ashwina kumar , gcc@gcc.gnu.org Cc: Subject: Re: GSOC In-Reply-To: User-Agent: Notmuch/0.28.3 (https://notmuchmail.org) Emacs/26.1 (x86_64-suse-linux-gnu) Date: Mon, 08 Apr 2019 11:27:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-04/txt/msg00113.txt.bz2 Hello, On Sun, Apr 07 2019, ashwina kumar wrote: > Hi , > > While working I just figured out that -Wconversion is buggy. Please see t= he > below code- - > > $ cat b.c > #include > > void main (void) > { > //contains build errors > uint16_t x =3D 1; > uint16_t y =3D 2; > y +=3D x; /* contains error */ > > } > > $ gcc b.c -Wconversion > b.c: In function =E2=80=98main=E2=80=99: > b.c:22:7: warning: conversion to =E2=80=98uint16_t {aka short unsigned in= t}=E2=80=99 > from =E2=80=98int=E2=80=99 may alter its value [-Wconversion] > y +=3D x; /* contains error */ > > Please help me to know as an GSOC student can I work on this for this year > to make -Wconversion more robust. Unfortunately I am not quite sure what you think is a problem. The option -Werror warns "for implicit conversions that may alter a value." In this case, the C language mandates that the addition is performed in full integer type, which is then stored to a shorter type, which is a conversion which may alter the value. Thus the warning. In this particular example the values are known constants and so one could argue that the result of addition is known at compile not to exceed the uint16_t range. However, the infrastructure that would have to be added to the C/C++ front-ends to perform such value tracking would not be justified with this simple use-case - especially given that the warning should be perfectly silence-able with an explicit conversion. Therefore, we are very unlikely to accept such GSoC proposal, sorry. Martin