Re: [Interest] can't dump QStringList with qDebug()

2023-03-07 Thread Thiago Macieira
On Tuesday, 7 March 2023 21:20:02 PST Hamish Moffatt via Interest wrote:
> I confirm that my test code compiles in 6.5.0-beta3.

And I can reproduce the error with GCC 13 if I check out the 6.4.2 headers.

GCC 13 says:

note: candidate: ‘template QDebugIfHasDebugStreamContainer, 
T> operator<<(QDebug, const QList&)’

note:   template argument deduction/substitution failed

qdebug.h:217:53:   required by substitution of ‘template 
QDebugIfHasDebugStreamContainer, T> operator<<(QDebug, const 
QList&) [with T = QString]’

type_traits:2594:11: error: no type named ‘type’ in ‘struct 
std::enable_if’

This is GCC speak for "condition evaluated to false"

By moving the constraint from the return type to a static_assert inside the 
function, I can prove that the ostream test fails:

qdebug.h:219:5: error: static assertion failed due to requirement 
'QTypeTraits::has_ostream_operator_v'

But that test is:
std::void_t() << 
detail::const_reference())>

and if I copy that expression to the function, it does compile.

Moreover, the changes to qdebug.h and qtypeinfo.h don't seem related.

So I have no clue *why* the check fails and *how* it was fixed.

This is template black magic. It works right now and I've spent enough time 
investigating.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering


smime.p7s
Description: S/MIME cryptographic signature
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] can't dump QStringList with qDebug()

2023-03-07 Thread Hamish Moffatt via Interest

On 8/3/23 14:45, Thiago Macieira wrote:

On Tuesday, 7 March 2023 17:21:11 PST Hamish Moffatt via Interest wrote:

I said gcc 10 earlier, but I meant to say clang 11. But I also see it in
clang 14, and in VS 2019 (17.5.1 - latest).

Cannot reproduce with those files with GCC 11, 12, 13 or Clang 15, all with Qt
6.6.

Looking at the generated assembly, I can also see the compiler realised the
list is always empty, so the loop from printSequentialContainer() disappears.f



I confirm that my test code compiles in 6.5.0-beta3.


thanks

Hamish

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] can't dump QStringList with qDebug()

2023-03-07 Thread Thiago Macieira
On Tuesday, 7 March 2023 17:21:11 PST Hamish Moffatt via Interest wrote:
> I said gcc 10 earlier, but I meant to say clang 11. But I also see it in
> clang 14, and in VS 2019 (17.5.1 - latest).

Cannot reproduce with those files with GCC 11, 12, 13 or Clang 15, all with Qt 
6.6.

Looking at the generated assembly, I can also see the compiler realised the 
list is always empty, so the loop from printSequentialContainer() disappears.f

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering


smime.p7s
Description: S/MIME cryptographic signature
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] can't dump QStringList with qDebug()

2023-03-07 Thread Hamish Moffatt via Interest

On 8/3/23 04:15, Thiago Macieira wrote:

On Monday, 6 March 2023 22:15:01 PST Hamish Moffatt via Interest wrote:

../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdebug.h:217:53: note:
candidate template ignored: requirement
'std::conjunction_v,
QString>, QTypeTraits::has_ostream_operator>>' was
not satisfied [with T = QString]

This is the expected template and the compiler told us why it couldn't expand:
it thinks that the QDebugIfHasDebugStreamContainer condition wasn't satisfied.
That condition is

std::is_base_of OR QTypeTraits::has_ostream_operator

Obviously, QStringList is not a base class of QString; we're expecting the
second check to be true, that there's an output streaming operator for QDebug-
QString

That of course is there; it's in QDebug itself.

So my conclusion is that your compiler has a bug and improperly parsed the C++
code. Does this problem happen with GCC 11 or 12?

I said gcc 10 earlier, but I meant to say clang 11. But I also see it in 
clang 14, and in VS 2019 (17.5.1 - latest).


It seems to be related to #including the moc output in the cpp file.


Here's a minimal example:

Header file:

#pragma once

#include 
#include 

namespace TServer
{

class Test : public QObject
{
Q_OBJECT

private:
void test();

signals:
void databaseOpened(QString schoolCode);
void databaseEvent(QString schoolCode, QString notification);
void databaseRemoved(QString schoolCode, QString dbFilename);
};

}


Source file:

#include "server_database2.h"
#include 

#include 


void TServer::Test::test()
{
qDebug() << QStringList{};
}



Hamish

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] can't dump QStringList with qDebug()

2023-03-07 Thread Thiago Macieira
On Monday, 6 March 2023 22:15:01 PST Hamish Moffatt via Interest wrote:
> ../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdebug.h:217:53: note:
> candidate template ignored: requirement
> 'std::conjunction_v,
> QString>, QTypeTraits::has_ostream_operator>>' was
> not satisfied [with T = QString]

This is the expected template and the compiler told us why it couldn't expand: 
it thinks that the QDebugIfHasDebugStreamContainer condition wasn't satisfied. 
That condition is 

std::is_base_of OR QTypeTraits::has_ostream_operator

Obviously, QStringList is not a base class of QString; we're expecting the 
second check to be true, that there's an output streaming operator for QDebug-
QString

That of course is there; it's in QDebug itself.

So my conclusion is that your compiler has a bug and improperly parsed the C++ 
code. Does this problem happen with GCC 11 or 12?

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering


smime.p7s
Description: S/MIME cryptographic signature
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] can't dump QStringList with qDebug()

2023-03-07 Thread Dmitriy Purgin
Hi,

I'm sure you have already tried it, but just a wild guess: do you have
#include  in this .cpp file?

Cheers
Dmitriy

On Tue, Mar 7, 2023 at 11:04 AM Hamish Moffatt via Interest <
interest@qt-project.org> wrote:

> On 7/3/23 20:11, Kai Köhne wrote:
> > Hi,
> >
> > This looks like a compiler issue to me.
> >>  const auto connections = QSqlDatabase::connectionNames();
> >>  qDebug() << "Closing open connections:" << connections;
> >>
> >> claiming that
> >> ../../../src/server/server_database.cpp:691:45: error: invalid operands
> to binary expression ('QDebug' and>
> >> 'const QList')
> > I think this is the place where it goes wrong:
> >
> >> ../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdebug.h:217:53: note:
> candidate template ignored: requirement
> 'std::conjunction_v,
> QString>, QTypeTraits::has_ostream_operator>>' was
> not satisfied [with T = QString]
> >> inline QDebugIfHasDebugStreamContainer, T> operator<<(QDebug
> debug, const QList )
> >>  ^
> > Anyhow, I couldn't reproduce this in a minimal example (and apparently
> you didn't manage either?). At minimum we need the exact compiler +
> compiler options passed on command line.
>
>
> It's happening in both Visual C++ and gcc 10, but on further
> investigation, only in one .cpp file; the same code in other files works
> fine. I'll keep investigating.
>
>
> thanks
>
> Hamish
>
> ___
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] can't dump QStringList with qDebug()

2023-03-07 Thread Hamish Moffatt via Interest

On 7/3/23 20:11, Kai Köhne wrote:

Hi,

This looks like a compiler issue to me.

 const auto connections = QSqlDatabase::connectionNames();
 qDebug() << "Closing open connections:" << connections;

claiming that
../../../src/server/server_database.cpp:691:45: error: invalid operands to binary 
expression ('QDebug' and>
'const QList')

I think this is the place where it goes wrong:


../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdebug.h:217:53: note: candidate template ignored: 
requirement 'std::conjunction_v, QString>, 
QTypeTraits::has_ostream_operator>>' was not satisfied [with T = QString]
inline QDebugIfHasDebugStreamContainer, T> operator<<(QDebug debug, const 
QList )
 ^

Anyhow, I couldn't reproduce this in a minimal example (and apparently you 
didn't manage either?). At minimum we need the exact compiler + compiler 
options passed on command line.



It's happening in both Visual C++ and gcc 10, but on further 
investigation, only in one .cpp file; the same code in other files works 
fine. I'll keep investigating.



thanks

Hamish

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] can't dump QStringList with qDebug()

2023-03-07 Thread Kai Köhne via Interest
Hi,

This looks like a compiler issue to me.
> const auto connections = QSqlDatabase::connectionNames();
> qDebug() << "Closing open connections:" << connections;
>
> claiming that
> ../../../src/server/server_database.cpp:691:45: error: invalid operands to 
> binary expression ('QDebug' and>
> 'const QList')

I think this is the place where it goes wrong: 

> ../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdebug.h:217:53: note: 
> candidate template ignored: requirement 
> 'std::conjunction_v, 
> QString>, QTypeTraits::has_ostream_operator>>' was not 
> satisfied [with T = QString]
> inline QDebugIfHasDebugStreamContainer, T> operator<<(QDebug debug, 
> const QList )
> ^

Anyhow, I couldn't reproduce this in a minimal example (and apparently you 
didn't manage either?). At minimum we need the exact compiler + compiler 
options passed on command line.

I also suggest to move this to bugreports.qt.io.

Regards

Kai

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] can't dump QStringList with qDebug()

2023-03-06 Thread Hamish Moffatt via Interest
I'm porting my code to Qt6 (6.4.2) (from 5.15) and ran into this 
mysterious problem; this code doesn't compile:


    const auto connections = QSqlDatabase::connectionNames();
    qDebug() << "Closing open connections:" << connections;


claiming that

../../../src/server/server_database.cpp:691:45: error: invalid operands 
to binary expression ('QDebug' and 'const QList')


It then lists all the candidates, of which there are many.  I have a 
simple test program that compiles OK though.


The same occurs on both Visual Studio/Windows and gcc 10/Linux.

Am I missing an include or something?


Hamish



../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdatastream.h:398:1: note: 
candidate function template not viable: no known conversion from 'QDebug' to 
'QDataStream &' for 1st argument
operator<<(QDataStream , const T )
^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdatastream.h:415:63: note: 
candidate function template not viable: no known conversion from 'QDebug' to 
'QDataStream &' for 1st argument
inline QDataStreamIfHasOStreamOperatorsContainer, T> operator<<(QDataStream , 
const QList )
  ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qobject.h:491:22: note: candidate 
function not viable: no known conversion from 'const QList' to 'const 
QObject *' for 2nd argument
Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *);
 ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtSql/qsqldatabase.h:105:21: note: candidate 
function not viable: no known conversion from 'const QList' to 'const 
QSqlDatabase' for 2nd argument
Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlDatabase &);
^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdebug.h:447:15: note: candidate 
function not viable: no known conversion from 'const QList' to 
'QKeyCombination' for 2nd argument
inline QDebug operator<<(QDebug debug, QKeyCombination combination)
  ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qiodevice.h:143:22: note: candidate 
function not viable: no known conversion from 'const QList' to 
'QIODevice::OpenMode' (aka 'QFlags') for 2nd argument
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QIODevice::OpenMode modes);
 ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qvariant.h:560:28: note: candidate 
function not viable: no known conversion from 'QDebug' to 'QDataStream &' for 
1st argument
Q_CORE_EXPORT QDataStream <<(QDataStream , const QVariant );
   ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qvariant.h:622:22: note: candidate 
function not viable: no known conversion from 'const QList' to 'const 
QVariant::Type' for 2nd argument
Q_CORE_EXPORT QDebug operator<<(QDebug, const QVariant::Type);
 ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlocale.h:1142:22: note: candidate 
function not viable: no known conversion from 'const QList' to 'const 
QLocale' for 2nd argument
Q_CORE_EXPORT QDebug operator<<(QDebug, const QLocale &);
 ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdatetime.h:540:22: note: candidate 
function not viable: no known conversion from 'const QList' to 'QDate' 
for 2nd argument
Q_CORE_EXPORT QDebug operator<<(QDebug, QDate);
 ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdatetime.h:541:22: note: candidate 
function not viable: no known conversion from 'const QList' to 'QTime' 
for 2nd argument
Q_CORE_EXPORT QDebug operator<<(QDebug, QTime);
 ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdatetime.h:542:22: note: candidate 
function not viable: no known conversion from 'const QList' to 'const 
QDateTime' for 2nd argument
Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &);
 ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qfileinfo.h:175:22: note: candidate 
function not viable: no known conversion from 'const QList' to 'const 
QFileInfo' for 2nd argument
Q_CORE_EXPORT QDebug operator<<(QDebug, const QFileInfo &);
 ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdir.h:244:22: note: candidate function not 
viable: no known conversion from 'const QList' to 'QDir::Filters' (aka 
'QFlags') for 2nd argument
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters);
 ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdir.h:245:22: note: candidate 
function not viable: no known conversion from 'const QList' to 'const 
QDir' for 2nd argument
Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QDir );
 ^
../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qregularexpression.h:166:22: note: 
candidate function not viable: no known conversion from 'const QList' 
to 'const QRegularExpression' for 2nd argument
Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QRegularExpression );
 ^