[Development] cast ... increases required alignment of target type [-Werror=cast-align]
Atlant Schmidt
aschmidt at dekaresearch.com
Wed Mar 7 12:57:34 CET 2012
Rohan:
Because no one more-authoritative has answered you,
I'll give it a try.
I think that this occurs because QVariant must have
sufficiently-strict alignment constraints to hold,
properly aligned, the largest POD datum that can be
stored in the variant. Other, more-specific objects
may be known to not have such a large POD datum
within them and so may have looser alignment
requirements.
When the more-loosely aligned object is cast to an
object type with tighter alignment constraints, the
compiler objects.
In this exact case, it doesn't look like it will hurt
you, but I think it would be good to code this in
such a way as to avoid the warning (without disabling
the warning). Unfortunately, I have no advice on how
to do this.
Atlant
-----Original Message-----
From: development-bounces+aschmidt=dekaresearch.com at qt-project.org [mailto:development-bounces+aschmidt=dekaresearch.com at qt-project.org] On Behalf Of Rohan McGovern
Sent: Tuesday, March 06, 2012 18:35
To: development
Subject: [Development] cast ... increases required alignment of target type [-Werror=cast-align]
Does anyone have a suggestion on how to fix this warning?
This code in qlist.h:
409: template <typename T>
410: Q_INLINE_TEMPLATE void QList<T>::node_destruct(Node *from, Node *to)
411: {
412: if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic)
413: while(from != to) --to, delete reinterpret_cast<T*>(to->v);
414: else if (QTypeInfo<T>::isComplex)
415: while (from != to) --to, reinterpret_cast<T*>(to)->~T();
416: }
...when compiled for ARM, causes this warning (or error with -Werror):
src/corelib/tools/qlist.h: In member function ‘void QList<T>::node_destruct(QList<T>::Node*, QList<T>::Node*) [with T = QVariant]’:
src/corelib/tools/qlist.h:738:5: instantiated from ‘void QList<T>::dealloc(QListData::Data*) [with T = QVariant]’
src/corelib/tools/qlist.h:714:9: instantiated from ‘QList<T>::~QList() [with T = QVariant]’
src/corelib/statemachine/qstatemachine.h:81:59: instantiated from here
src/corelib/tools/qlist.h:415:28: error: cast from ‘QList<QVariant>::Node*’ to ‘QVariant*’ increases required alignment of target type [-Werror=cast-align]
"do not compile with -Wcast-align" may be a valid answer, but it would
be good to hear from someone who can confidently say whether or not this
issue can actually harm us in practice.
_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development
Click https://www.mailcontrol.com/sr/QilNO59cSRvTndxI!oX7UsdpzMR7Bo2K9vbOG+MDi5IDPn0IJCwStGrlGy1xFX8KHjzlD+HXh2sua8zCo+pDiw== to report this email as spam.
This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
Thank you.
Please consider the environment before printing this email.
More information about the Development
mailing list