tags:

views:

175

answers:

1

I'm trying to create the following data structure in Qt 4.5 in C++:

QMap<int, QMap<QString, QVector<QPointF> > > animation;

However, the inclusion of this line in my code results in the following error:

cc1plus: warnings being treated as errors
In file included from XXX/XXX/XXX/MainWindow.qt.C.tmp.C:113:
/usr/lib/qt4/include/QtCore/qmap.h: In member function ‘void MainWindow::exportAnn()’:
/usr/lib/qt4/include/QtCore/qmap.h:588: error: dereferencing pointer ‘y’ does break strict-aliasing rules
/usr/lib/qt4/include/QtCore/qmap.h:586: note: initialized from here
Command exited with non-zero status 1

My organization requires me to treat all warnings as errors, so I can't simply ignore this. Is this a bug in Qt, or is there something I'm doing wrong?

+4  A: 

The code you mention works fine with Qt 4.6.1 and GCC 4.4.1 on Intel/Mac OS X.

$ cat a.cpp #include <QtCore>
void foo (QMap<int, QMap<QString, QVector<QPointF> > > &map)
  { map.clear(); }
$ g++-4.4-fsf -c -DQT_CORE_LIB -DQT_SHARED -I/Library/Frameworks/QtCore.framework/Versions/4/Headers a.cpp -W -Wall -Werror -g -O3 -fPIC
$

So your issue is probably fixed by upgrading to Qt 4.6.1. (Unless it's a compiler target-specific bug, which seems unlikely; plus, you haven't told us what platform you're compiling on.)

FX