| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 4 | |
Hi
I think I found a bug in moc. I would like to explain the bug and I also have fixed the problem. Please tell me how can I send the patch for this problem.
I am new at this mailing list. A bug report should go to other place, please let me know.
Environment: Qt4.2.2, SuSE Linux 10.1, gcc 4.1.0.
Could you please have a look at next code?
-----
#include <QObject>
namespace AAA {
/** \class BaseA
This is almost nothing, but in the namesapace AAA.
*/
class BaseA {
public:
BaseA(){}
virtual ~BaseA(){}
};
} // namesapace AAA
namespace BBB {
/** \class DerivedB
*/
class DerivedB : public QObject, public ::AAA::BaseA {
Q_OBJECT
public:
DerivedB() : QObject(0), BaseA() {}
virtual ~DerivedB() {}
public slots:
signals:
private:
};
} //namespace BBB
---
When you compile the code, you will get next errors from gcc.
MocDigraphTrap.moc.cc: In member function `virtual void* BBB::DerivedB::qt_metacast(const char*)':
MocDigraphTrap.moc.cc:52: error: expected `<' before '[' token
MocDigraphTrap.moc.cc:52: error: expected identifier before '[' token
MocDigraphTrap.moc.cc:52: error: expected `>' before '[' token
MocDigraphTrap.moc.cc:52: error: expected `(' before '[' token
MocDigraphTrap.moc.cc:52: error: expected primary-expression before '[' token
MocDigraphTrap.moc.cc:52: error: expected primary-expression before ':' token
MocDigraphTrap.moc.cc:52: error: expected `]' before ':' token
MocDigraphTrap.moc.cc:52: error: expected `)' before ':' token
MocDigraphTrap.moc.cc:52: error: expected `;' before ':' token
MocDigraphTrap.moc.cc:52: error: expected primary-expression before ':' token
MocDigraphTrap.moc.cc:52: error: expected `;' before ':' token
-----
The error happens in the MocDigraphTrap.moc.cc:52, which is
return static_cast<::AAA::BaseA*>(const_cast<DerivedB*>(this));
in the next function qt_metacast().
---
void *BBB::DerivedB::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_BBB__DerivedB))
return static_cast<void*>(const_cast<DerivedB*>(this));
if (!strcmp(_clname, "::AAA::BaseA"))
return static_cast<::AAA::BaseA*>(const_cast<DerivedB*>(this));
return QObject::qt_metacast(_clname);
}
---
The error said there is no token < before [. No such token you can see, I think. This is because ISO standard (1999) digraph.
(see http://david.tribble.com/text/cdiffs.htm#C90-digraph)
I think C's Trigraph has enough bad reputation, but the digraph may be not yet. According to the standard, cpp must change '<:' to '['. So, you can not write std::vector<::some>. (In a template case, gcc gives us really useful error message, but the cast case is not.) Qt4's moc may not consider this situation.
But actually, if you zap the src/tools/moc/generator.cpp, some of the reinterpred_cast knows this problem. I do not see why the writer did not put a space to static_cast....
Anyway, this bug is easy to fix, can I put my patch for src/tools/moc/generate.cpp to here?
Thank you!
Gruesse,
Hitoshi Yamauchi
--
[ signature omitted ]
On 12/16/06, hito111@xxxxxx <hito111@xxxxxx> wrote: > Hi > > I think I found a bug in moc. I would like to explain the bug and I also have fixed the problem. Please tell me how can I send the patch for this problem. Great for finding both the bug and solution. > I am new at this mailing list. A bug report should go to other place, please let me know. They should go directly to Trolltech, qt-bugs (at) trolltech.com. -- [ signature omitted ]
Hi, Von: "Robin Ericsson" > On 12/16/06, hito111@xxxxxx <hito111@xxxxxx> wrote: > > I think I found a bug in moc. I would like to explain the bug and I also > have fixed the problem. Please tell me how can I send the patch for this > problem. > > Great for finding both the bug and solution. > > > I am new at this mailing list. A bug report should go to other place, > please let me know. > > They should go directly to Trolltech, qt-bugs (at) trolltech.com. Thanks! I will send this to qt-bugs. Best Regards, Hitoshi Yamauchi -- [ signature omitted ]
On Saturday 16 December 2006 21:57, hito111@xxxxxx wrote:
> Hi
>
> I think I found a bug in moc. I would like to explain the bug and I also
> have fixed the problem. Please tell me how can I send the patch for this
> problem.
>
> I am new at this mailing list. A bug report should go to other place,
> please let me know.
>
> Environment: Qt4.2.2, SuSE Linux 10.1, gcc 4.1.0.
>
> Could you please have a look at next code?
> -----
> #include <QObject>
> namespace AAA {
> /** \class BaseA
> This is almost nothing, but in the namesapace AAA.
> */
> class BaseA {
> public:
> BaseA(){}
> virtual ~BaseA(){}
> };
> } // namesapace AAA
>
> namespace BBB {
> /** \class DerivedB
> */
> class DerivedB : public QObject, public ::AAA::BaseA {
> Q_OBJECT
> public:
> DerivedB() : QObject(0), BaseA() {}
> virtual ~DerivedB() {}
> public slots:
> signals:
> private:
> };
> } //namespace BBB
> ---
>
> When you compile the code, you will get next errors from gcc.
>
> MocDigraphTrap.moc.cc: In member function `virtual void*
> BBB::DerivedB::qt_metacast(const char*)': MocDigraphTrap.moc.cc:52: error:
> expected `<' before '[' token
> MocDigraphTrap.moc.cc:52: error: expected identifier before '[' token
> MocDigraphTrap.moc.cc:52: error: expected `>' before '[' token
> MocDigraphTrap.moc.cc:52: error: expected `(' before '[' token
> MocDigraphTrap.moc.cc:52: error: expected primary-expression before '['
> token MocDigraphTrap.moc.cc:52: error: expected primary-expression before
> ':' token MocDigraphTrap.moc.cc:52: error: expected `]' before ':' token
> MocDigraphTrap.moc.cc:52: error: expected `)' before ':' token
> MocDigraphTrap.moc.cc:52: error: expected `;' before ':' token
> MocDigraphTrap.moc.cc:52: error: expected primary-expression before ':'
> token MocDigraphTrap.moc.cc:52: error: expected `;' before ':' token
> -----
>
> The error happens in the MocDigraphTrap.moc.cc:52, which is
>
> return static_cast<::AAA::BaseA*>(const_cast<DerivedB*>(this));
>
> in the next function qt_metacast().
>
> ---
> void *BBB::DerivedB::qt_metacast(const char *_clname)
> {
> if (!_clname) return 0;
> if (!strcmp(_clname, qt_meta_stringdata_BBB__DerivedB))
> return static_cast<void*>(const_cast<DerivedB*>(this));
> if (!strcmp(_clname, "::AAA::BaseA"))
> return static_cast<::AAA::BaseA*>(const_cast<DerivedB*>(this));
> return QObject::qt_metacast(_clname);
> }
> ---
>
> The error said there is no token < before [. No such token you can see, I
> think. This is because ISO standard (1999) digraph. (see
> http://david.tribble.com/text/cdiffs.htm#C90-digraph)
>
> I think C's Trigraph has enough bad reputation, but the digraph may be not
> yet. According to the standard, cpp must change '<:' to '['. So, you can
> not write std::vector<::some>. (In a template case, gcc gives us really
> useful error message, but the cast case is not.) Qt4's moc may not consider
> this situation.
>
> But actually, if you zap the src/tools/moc/generator.cpp, some of the
> reinterpred_cast knows this problem. I do not see why the writer did not
> put a space to static_cast....
>
> Anyway, this bug is easy to fix, can I put my patch for
> src/tools/moc/generate.cpp to here?
>
> Thank you!
Well spotted! Thanks a lot for the report. It'll be fixed in tomorrow's
4.2/4.3 snapshots.
Simon
Attachment:
Attachment:
pgpqqeAw22C6F.pgp
Description: PGP signature