Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't compile with GCC (MinGW 4.8.1) #12

Open
coderalpha opened this issue Jun 9, 2014 · 3 comments
Open

Doesn't compile with GCC (MinGW 4.8.1) #12

coderalpha opened this issue Jun 9, 2014 · 3 comments

Comments

@coderalpha
Copy link

I tried to compile master with various errors and then tried the released version 1.0, with the following error.
The class column contains a private const member variable:

const Attributes m_attributes;

which result in the following error:

C:\Temp\QSqlMigrator-1.0\src\Structure\Column.h:40: error: non-static const member 'const Attributes Structure::Column::m_attributes', can't use default assignment operator
 class QSQLMIGRATOR_DLL_EXPORT Column
@arBmind
Copy link
Member

arBmind commented Jun 9, 2014

Thank you for triing out QSqlMigrator.
I encountered the bug myself. Unfortunately this seems to be a bug in QList implementation.

in qlist.h (Qt 5.3.0 line 370):

template <typename T>
Q_INLINE_TEMPLATE void QList<T>::node_construct(Node *n, const T &t)
{
    if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) n->v = new T(t);
    else if (QTypeInfo<T>::isComplex) new (n) T(t);
#if (defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__IBMCPP__)) && !defined(__OPTIMIZE__)
    // This violates pointer aliasing rules, but it is known to be safe (and silent)
    // in unoptimized GCC builds (-fno-strict-aliasing). The other compilers which
    // set the same define are assumed to be safe.
    else *reinterpret_cast<T*>(n) = t;
#else
    // This is always safe, but penaltizes unoptimized builds a lot.
    else ::memcpy(n, static_cast<const void *>(&t), sizeof(T));
#endif
}

For some compilers in debug mode !defined(OPTIMIZE) the copy operator may be used. The Column type is complex therefore this path is not used. But as everything is in one method, divided only by if-else-statements. The code does not compile.

For a solution:

  1. compile with optimization (that's what we did so far)
  2. Qt resolves the issue ( https://bugreports.qt-project.org/browse/QTBUG-39545 )
  3. remove the const-correctness of Column, by adding assign operator. It may throw an exception, but we lose the early warning of the compiler. (my least favorite solution)

@coderalpha
Copy link
Author

Thanks for the quick response!

I will try the optimization switch, is it turning optimization on or off?

Are you aware of the compile errors of the master branch?

@arBmind
Copy link
Member

arBmind commented Jun 12, 2014

You should turn optimization on, to avoid the QList-Bug. If you use the provide .pro files, you can simply use the Release mode.

No. The master Branch/Release 1.5 compiles without any errors. See Travis-Build. If you still have issues with that, feel free to open a new bug issue and I will see what I can do.

arBmind added a commit that referenced this issue Sep 20, 2021
* modernize Appveyor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants