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++/43933] New: Suboptimal error message when supplying a bad default value in initialization


When doing something like this:

class A {
    A();
    QString a;
};

A::A():a(0) {
}

The error message is


test.cpp: In constructor ?ScribusDoc::ScribusDoc()?:                            
test.cpp:6:12: error: call of overloaded ?QString(int)? is ambiguous
/usr/lib64/qt4/include/QtCore/qstring.h:427:43: note: candidates are:
QString::QString(const QByteArray&)
/usr/lib64/qt4/include/QtCore/qstring.h:425:43: note:                
QString::QString(const char*)
/usr/lib64/qt4/include/QtCore/qstring.h:726:8: note:                
QString::QString(const QString&)
/usr/lib64/qt4/include/QtCore/qstring.h:106:5: note:                
QString::QString(QChar)
/usr/lib64/qt4/include/QtCore/qstring.h:105:14: note:                
QString::QString(const QChar*)


It would be useful if there was an indication of which initializer is being
processed at the time, e.g.

test.cpp: In constructor ?ScribusDoc::ScribusDoc()?:                            
test.cpp:6:12: error: call of overloaded ?QString(int)? is ambiguous while
initializing member ?a'
/usr/lib64/qt4/include/QtCore/qstring.h:427:43: note: candidates are:
QString::QString(const QByteArray&)
/usr/lib64/qt4/include/QtCore/qstring.h:425:43: note:                
QString::QString(const char*)
/usr/lib64/qt4/include/QtCore/qstring.h:726:8: note:                
QString::QString(const QString&)
/usr/lib64/qt4/include/QtCore/qstring.h:106:5: note:                
QString::QString(QChar)
/usr/lib64/qt4/include/QtCore/qstring.h:105:14: note:                
QString::QString(const QChar*)

especially if the class initializes tens of variables rather than just one.


-- 
           Summary: Suboptimal error message when supplying a bad default
                    value in initialization
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bero at arklinux dot org


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


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