This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/44924] Broken htons, invalid conversion warning
- From: "ralgith at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Jul 2010 20:17:44 -0000
- Subject: [Bug c++/44924] Broken htons, invalid conversion warning
- References: <bug-44924-15287@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from ralgith at gmail dot com 2010-07-12 20:17 -------
(In reply to comment #3)
> >-Wconversion
> Will cause this warning.
>
>
> sa.sin_port = (__extension__ ({ register unsigned short int __v, __x =
> (siteinfo->port); if (__builtin_constant_p (__x)) __v = ((((__x) >> 8) & 0xff)
> | (((__x) & 0xff) << 8)); else __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x)
> : "cc"); __v; }));
>
>
> __v = ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8));
> is the part which is causing the warning. The issue is the (__x) >> 8 is
> implictly casted into int.
>
Yet, if I remove the optimization flag -Os and keep the -Wconversion it doesn't
generate the warning. So there's still an issue here, even if the issue is that
-Wconversion is MISSING this when the code isn't optimized. Or perhaps I'm
missing something else here.
Regardless, is there a work around? I really enjoy using all my optimization
and -W flags because I like to have the best code possible. Thanks.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44924