This is the mail archive of the gcc-bugs@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]

[Bug c++/44924] Broken htons, invalid conversion warning



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]