gcc4 warnings -Wuninitialized -Wfloat-equal and -Wconversion

David Faure faure at kde.org
Tue Sep 22 17:03:47 BST 2009


On Monday 14 September 2009, Jaime Torres wrote:
> On Monday 14 September 2009 11:41:18 David Faure wrote:
> > But I don't know how to fix the warnings that come from member vars that
> > use bitfields though.
> 
> This is what I've found:
> 
> Use of signed:1 bit-fields is usually a mistake in the code, since the
> user doesn't normally intend to use values 0 and -1. Warning if 1 might
> be stored in such a bit-field seems appropriate for -Wconversion.

But I get warnings even with unsigned bitfields:
src/gui/text/qtextoption.h:97: warning: conversion to 'unsigned char:1' from 'uint' may alter its value

The line is
inline void setTextDirection(Qt::LayoutDirection aDirection) { this->direction = aDirection; }

The types are defined as

    enum LayoutDirection {
        LeftToRight,
        RightToLeft
    };

   uint direction : 1;

I tried uint(aDirection), static_cast<uint>(aDirection), and static_cast<uchar>(aDirection),
no difference.
It looks like it wants static_cast<uchar:1>(aDirection) but that syntax doesn't exist :-)

-- 
David Faure, faure at kde.org, sponsored by Nokia to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list