This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61760] -Wconversion inconsistency between gcc and g++
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 09 Jul 2014 19:03:18 +0000
- Subject: [Bug c++/61760] -Wconversion inconsistency between gcc and g++
- Auto-submitted: auto-generated
- References: <bug-61760-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61760
Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-07-09
CC| |manu at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
The C FE produces:
<nop_expr 0x7ffff751dfe0
type <integer_type 0x7ffff740a690 int public SI
size <integer_cst 0x7ffff74088b8 constant 32>
unit size <integer_cst 0x7ffff74088d0 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x7ffff740a690 precision
32 min <integer_cst 0x7ffff7408870 -2147483648> max <integer_cst 0x7ffff7408888
2147483647>
pointer_to_this <pointer_type 0x7ffff7415738>>
arg 0 <rshift_expr 0x7ffff750eac8
type <integer_type 0x7ffff740a3f0 unsigned char public unsigned
string-flag QI
size <integer_cst 0x7ffff7408768 constant 8>
unit size <integer_cst 0x7ffff7408780 constant 1>
align 8 symtab 0 alias set -1 canonical type 0x7ffff740a3f0
precision 8 min <integer_cst 0x7ffff7408798 0> max <integer_cst 0x7ffff7408738
255>>
arg 0 <parm_decl 0x7ffff7531000 x type <integer_type 0x7ffff740a3f0
unsigned char>
used unsigned QI file /home/manuel/test.c line 1 col 33 size
<integer_cst 0x7ffff7408768 8> unit size <integer_cst 0x7ffff7408780 1>
align 8 context <function_decl 0x7ffff7514700 foo> arg-type
<integer_type 0x7ffff740a3f0 unsigned char>>
arg 1 <integer_cst 0x7ffff7408a20 constant 1>>
/home/manuel/test.c:3:12>
that is (int) (x >> 1).
The C++ FE produces:
<rshift_expr 0x7ffff75603e8
type <integer_type 0x7ffff740a690 int public SI
size <integer_cst 0x7ffff7408a68 constant 32>
unit size <integer_cst 0x7ffff7408a80 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x7ffff740a690 precision
32 min <integer_cst 0x7ffff7408a20 -2147483648> max <integer_cst 0x7ffff7408a38
2147483647>
pointer_to_this <pointer_type 0x7ffff741c738>>
arg 0 <nop_expr 0x7ffff7576220 type <integer_type 0x7ffff740a690 int>
arg 0 <parm_decl 0x7ffff7577080 x type <integer_type 0x7ffff740a3f0
unsigned char>
used unsigned QI file /home/manuel/test.c line 1 col 33
size <integer_cst 0x7ffff7408918 constant 8>
unit size <integer_cst 0x7ffff7408930 constant 1>
align 8 context <function_decl 0x7ffff7567b00 foo>
arg-type <integer_type 0x7ffff740a690 int>>>
arg 1 <integer_cst 0x7ffff7408bd0 type <integer_type 0x7ffff740a690 int>
constant 1>
/home/manuel/test.c:3:12>
that is (((int)x) >> 1)
I am not sure which one is more correct, but the latter prevents
unsafe_conversion_p from seeing that the implicit conversion cannot alter the
value.