[Bug c++/39191] New: Wrong warning with control reaches end of non-void function

alpha dot super-one at laposte dot net gcc-bugzilla@gcc.gnu.org
Sat Feb 14 09:24:00 GMT 2009


In this code:
//Load a style icon as a pixmap
QPixmap loadImagePixmap(const QString& fileName)
{
        for (int i = 0; i < cacheOfPixmaps.size(); ++i) {
                if(ScacheOfPixmaps.at(i)==fileName)
                        return cacheOfPixmaps.at(i);
        }
        QString fullPath=loadFilePathIntheStyle(fileName);
        if(!QFile::exists(fullPath))
        {
                return QPixmap();
                DEBUGCONSOLE(10,"loadImagePixmap",fileName+" not found.");
        }
        else
        {
                QPixmap theReturnedImage(fullPath);
                if(theReturnedImage.isNull())
                {
                        DEBUGCONSOLE(10,"loadImagePixmap",fileName+" can't be
opened.");
                }
                else
                {
                        cacheOfPixmaps.append(theReturnedImage);
                        ScacheOfPixmaps.append(fileName);
                }
                return theReturnedImage;
        }
}
It's say me:
main.cpp: In function 'QPixmap loadImagePixmap(const QString&)':
main.cpp:313: warning: control reaches end of non-void function
It's wrong because need always return a value.


-- 
           Summary: Wrong warning with control reaches end of non-void
                    function
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alpha dot super-one at laposte dot net
  GCC host triplet: linux x86_64
GCC target triplet: linux x86_64


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39191



More information about the Gcc-bugs mailing list