This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/32643] [4.3 Regression] Wrong error message with unsigned char a = uchar&512
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jul 2007 10:19:52 -0000
- Subject: [Bug c/32643] [4.3 Regression] Wrong error message with unsigned char a = uchar&512
- References: <bug-32643-6528@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from pinskia at gcc dot gnu dot org 2007-07-08 10:19 -------
(In reply to comment #3)
> > We don't reject as invalid code either:
> > unsigned char p;
> > unsigned char p1 = p & 0;
>
> Why should we? There is no overflow here, you mean that p is not constant? I
> think we have two issues in the first testcase, one is folding (X op 0), the
> other is converting 512 to uchar before performing the operation. Am I wrong?
Yes, the converting 512 to uchar is a valid optimization. That is:
(char)(((int) a) & b)
is the same as:
a & ((char)b)
if a is of type char.
as there are no overflow concerns with AND.
The folding gets us to the case where we have "a & 0" which is not a valid
constant initializer at all.
Note I found this while working on fixing PR 32628, where the patch which fixes
that caues us to no longer emit a warning/error for the first testcase.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |32628
nThis| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32643