This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/34198] -Wconversion gives apparent erroneous warning with g++ 4.3-20071109
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Nov 2007 23:04:38 -0000
- Subject: [Bug c++/34198] -Wconversion gives apparent erroneous warning with g++ 4.3-20071109
- References: <bug-34198-15412@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from jakub at gcc dot gnu dot org 2007-11-22 23:04 -------
See the shorten code in e.g. c-typeck.c's build_binary_op.
I think there are two possible fixes:
1) if shortening (i.e. final_type != result_type) don't convert_and_check
to result_type, but instead convert to result_type, and
warnings_for_convert_and_check to final_type
2) in conversion_warning's != REAL_CST != INTEGER_CST
TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
&& TREE_CODE (type) == INTEGER_TYPE case use get_narrower to see if
expr is zero or sign extended some smaller type.
If say type is unsigned char and expr is (int) b where unsigned char b;
then we shouldn't really warn, the conversions together can't alter
its value, nor change sign etc.
I think 2) is strongly preferrable.
Will try a patch tomorrow^H^H^H^H^H^H^H^Htoday.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-11-22 22:43:19 |2007-11-22 23:04:36
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34198