[Development] cast ... increases required alignment of target type [-Werror=cast-align]
Rohan McGovern
rohan.mcgovern at nokia.com
Wed Mar 7 10:36:17 CET 2012
Thiago Macieira said:
> On quarta-feira, 7 de março de 2012 09.34.35, Rohan McGovern wrote:
> > 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: }
>
> > src/corelib/tools/qlist.h:415:28: error: cast from
> > ‘QList<QVariant>::Node*’ to ‘QVariant*’ increases required alignment of
> > target type [-Werror=cast-align]
>
> There is an increased alignment requirement in there. However, the side of the
> branch being considered, line 415, is never executed because isLarge == true.
> So this warning is a false positive on a line that gets never compiled.
>
Thanks, so can we use #pragma GCC diagnostic to selectively silence
warnings like this? There doesn't seem to be much precedent for it so
far (just one usage I can find in qatomic.h).
More information about the Development
mailing list