This is the mail archive of the
mailing list for the GCC project.
Re: question regarding new warning
- From: mveksler at tx dot technion dot ac dot il
- To: Andrew Haley <aph at redhat dot com>
- Cc: Florian Weimer <fweimer at redhat dot com>, Daniel Gutson <daniel dot gutson at tallertechnologies dot com>, gcc at gcc dot gnu dot org
- Date: Thu, 27 Mar 2014 18:51:10 +0200
- Subject: Re: question regarding new warning
- Authentication-results: sourceware.org; auth=none
- References: <CAF5HaEV2vt=epA4h-rPGDNnXtUFWXhJeqyAF0k06b1Wuoec97g at mail dot gmail dot com> <5333D6F5 dot 5080008 at redhat dot com> <5333E6CD dot 1030209 at redhat dot com> <5333FC4B dot 8080901 at redhat dot com>
Quoting Andrew Haley <email@example.com>:
On 03/27/2014 08:52 AM, Florian Weimer wrote:
On 03/27/2014 08:44 AM, Andrew Haley wrote:
On 03/26/2014 03:05 PM, Daniel Gutson wrote:
assigning a negative literal to an unsigned variable issues
unsigned int x;
x =- 4;
This is specially important in typos when -= was intended instead of =-
Would be acceptable if I add a new warning to handle this, i.e.
Assigning a negative literal to an unsigned variable is well-defined
standard C. Is it really appropriate to warn for correct code?
Yes, this warning needs to take whitespace into account. But then, I
suppose it would be fine.
What about when x is signed, and what about
x =+ 4;
They are equally valid but, again, look fishy.
Why limit the warning to 'x =- 4' when x is unsigned?
This reminds me of the following C scenario:
while (t= strchr(t, ' ')) ....
Which generates a warning despite being perfectly valid.