This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Quoting Andrew Haley <aph@redhat.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 no warning: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. -Wnegative-to-unsigned or alike?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.I agree.
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. Michael
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |