Bug 10080

Summary: wrong header
Product: Sisyphus Reporter: inger <inger>
Component: libqt4-develAssignee: Sergey V Turchin <zerg>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: normal    
Priority: P2 CC: zerg
Version: unstable   
Hardware: all   
OS: Linux   

Description inger@altlinux.org 2006-10-03 14:36:19 MSD
при попытке использовать findChildren
--
QList<alWidget *> children = el->findChildren<alWidget *>();
--
В режиме -O2 (то есть с включённым strict aliasing), получаю предупреждение:
--
/usr/include/qt4/QtCore/qobject.h: In function 'QList<T> qFindChildren(const
QObject*, const QString&) [with T = alWidget*]':
/usr/include/qt4/QtCore/qobject.h:145:   instantiated from 'QList<T>
QObject::findChildren(const QString&) const [with T = alWidget*]'
browser.cc:102:   instantiated from here
/usr/include/qt4/QtCore/qobject.h:369: warning: type-punning to incomplete type
might break strict-aliasing rules
---

Эксперты говорят, что это происходит из-за того что в заголовочном файле
применяется: void**
--
template<typename T>
inline QList<T> qFindChildren(const QObject *o, const QString &name)
{
    QList<T> list;
    qt_qFindChildren_helper(o, name, 0, reinterpret_cast<T>(0)->staticMetaObject,
                         reinterpret_cast<QList<void *>*>(&list));
    return list;
}
--

Возможно тут надо проконсультироваться с upstream на эту тему.

Steps to Reproduce:
1. Пишем программу:
--- L.cc
#include <QtCore/QObject> 
#include <QtCore/QList> 

int main()
{
        QObject o;
        QList<QObject*> children = o.findChildren<QObject *>();
}
---
2. Компилируем:

$ gcc -c -Wall -W -O2  -I /usr/lib/qt4/include/ L.cc 
/usr/lib/qt4/include/QtCore/qobject.h: In function 'QList<T> qFindChildren(const
QObject*, const QString&) [with T = QObject*]':
/usr/lib/qt4/include/QtCore/qobject.h:145:   instantiated from 'QList<T>
QObject::findChildren(const QString&) const [with T = QObject*]'
L.cc:7:   instantiated from here
/usr/lib/qt4/include/QtCore/qobject.h:369: warning: type-punning to incomplete
type might break strict-aliasing rules

3.
Comment 1 Sergey V Turchin 2007-08-14 18:55:07 MSD
не воспроизводиться на libqt4-4.3.1-alt1