Opened 7 years ago

Closed 7 years ago

#54183 closed defect (fixed)

qt4-mac @4.8.7: build failures with clang-4.0 due to comparison between pointer and zero

Reported by: kencu (Ken) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: michaelld (Michael Dickens), devernay (Frédéric Devernay)
Port: qt4-mac

Description

Apparently clang-4.0 has elevated a test like:

if (somepointer > 0)

to an error. <https://github.com/ZoneMinder/ZoneMinder/issues/1760>

I suspect this will probably result in a number of builds breaking, but so far in building qt4-mac there have been a couple, and I'm just getting into it. I'm going to go back to clang-3.9 to build this, while we sort out all the errors over time.

Perhaps there is a flag to turn this off.

In file:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_aqua_qt4-mac/qt4-mac/work/qt-everywhere-opensource-src-4.8.7/src/3rdparty/webkit/Source/WebCore/html/HTMLImageElement.cpp

../JavaScriptCore/runtime/JSTypeInfo.h:73:52: note: remove constant to silence this warning
        unsigned isFinal() const { return m_flags2 && (IsJSFinalObject >> 8); }
                                                  ~^~~~~~~~~~~~~~~~~~~~~~~~~
html/HTMLImageElement.cpp:77:24: error: ordered comparison between pointer and zero ('const int *' and 'int')
    if (optionalHeight > 0)

and

/opt/local/bin/clang++-mp-4.0 -c -pipe -Os -stdlib=libc++ -Xarch_i386 -mmacosx-version-min=10.6 -Xarch_x86_64 -mmacosx-version-min=10.6 -O2 -Wall -W -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.6 -arch i386 -DPROEVALUATOR_CUMULATIVE -DPROEVALUATOR_INIT_PROPS -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_XML_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -DQT_HAVE_AVX -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_SHARED -I../../../mkspecs/macx-g++ -I. -I.moc/release-shared -I../../../lib/QtCore.framework/Versions/4/Headers -I../../../lib/QtXml.framework/Versions/4/Headers -I../shared -I../../../src/declarative/qml/parser -I../../../src/declarative/qml -I../../../include/QtDeclarative -I../../../include/QtXml -I../../../include/QtCore -I../../../include -F/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_aqua_qt4-mac/qt4-mac/work/qt-everywhere-opensource-src-4.8.7/Library/Frameworks -F/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_aqua_qt4-mac/qt4-mac/work/qt-everywhere-opensource-src-4.8.7/lib -o .obj/release-shared/qscript.o qscript.cpp
/opt/local/bin/clang++-mp-4.0 -c -pipe -Os -stdlib=libc++ -Xarch_i386 -mmacosx-version-min=10.6 -Xarch_x86_64 -mmacosx-version-min=10.6 -O2 -Wall -W -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.6 -arch i386 -DPROEVALUATOR_CUMULATIVE -DPROEVALUATOR_INIT_PROPS -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_XML_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -DQT_HAVE_AVX -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_SHARED -I../../../mkspecs/macx-g++ -I. -I.moc/release-shared -I../../../lib/QtCore.framework/Versions/4/Headers -I../../../lib/QtXml.framework/Versions/4/Headers -I../shared -I../../../src/declarative/qml/parser -I../../../src/declarative/qml -I../../../include/QtDeclarative -I../../../include/QtXml -I../../../include/QtCore -I../../../include -F/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_aqua_qt4-mac/qt4-mac/work/qt-everywhere-opensource-src-4.8.7/Library/Frameworks -F/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_aqua_qt4-mac/qt4-mac/work/qt-everywhere-opensource-src-4.8.7/lib -o .obj/release-shared/qdeclarative.o qdeclarative.cpp
/opt/local/bin/clang++-mp-4.0 -c -pipe -Os -stdlib=libc++ -Xarch_i386 -mmacosx-version-min=10.6 -Xarch_x86_64 -mmacosx-version-min=10.6 -O2 -Wall -W -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.6 -arch i386 -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQFORMINTERNAL_NAMESPACE -DQT_KEYWORDS -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -DQT_HAVE_AVX -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_SHARED -I../../../mkspecs/macx-g++ -I. -I.moc/release-shared -I../../../include/QtUiTools -I../../../lib/QtCore.framework/Versions/4/Headers -I../../../lib/QtGui.framework/Versions/4/Headers -I../../../lib/QtXml.framework/Versions/4/Headers -I../shared -I../../designer/src/uitools -I../../designer/src/lib/uilib -I../../../include/QtXml -I../../../include/QtGui -I../../../include/QtCore -I../../../include -I.uic/release-shared -F/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_aqua_qt4-mac/qt4-mac/work/qt-everywhere-opensource-src-4.8.7/Library/Frameworks -F/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_aqua_qt4-mac/qt4-mac/work/qt-everywhere-opensource-src-4.8.7/lib -o .obj/release-shared/messagemodel.o messagemodel.cpp
In file included from qdeclarative.cpp:51:
../../../src/declarative/qml/parser/qdeclarativejsparser_p.h:175:17: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
            if (! d.kind == DiagnosticMessage::Warning)
                ^        ~~
../../../src/declarative/qml/parser/qdeclarativejsparser_p.h:175:17: note: add parentheses after the '!' to evaluate the comparison first
            if (! d.kind == DiagnosticMessage::Warning)
                ^
                  (                                   )
../../../src/declarative/qml/parser/qdeclarativejsparser_p.h:175:17: note: add parentheses around left hand side expression to silence this warning
            if (! d.kind == DiagnosticMessage::Warning)
                ^
                (       )
1 warning generated.
messagemodel.cpp:186:61: error: ordered comparison between pointer and zero ('MessageItem *' and 'int')
                if (c->findMessage(m->text(), m->comment()) >= 0)
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~
1 error generated.

Change History (9)

comment:1 Changed 7 years ago by michaelld (Michael Dickens)

I was always taught to just do

if (pointer) ...

which implicitly compares it with whatever type of 0 the pointer is. That's been valid in C since I started using it, gotta be 30 years now. As far as I know, it's still valid in C or C++. Maybe frowned upon by modern standards which might use C++11's nullptr. Not sure what the equivalent in C is.

Can you do a simple program & test to see if this works on your 10.6 setup?

If so, then I'd say to patch those explicit comparisons with 0 to be this type. Single patch would do.

comment:2 Changed 7 years ago by devernay (Frédéric Devernay)

Version 3, edited 7 years ago by devernay (Frédéric Devernay) (previous) (next) (diff)

comment:3 Changed 7 years ago by devernay (Frédéric Devernay)

Cc: devernay added

comment:4 Changed 7 years ago by michaelld (Michael Dickens)

@deverney: Intersting & good to know.

Does anyone have a list of these strange pointer comparisons? I'm trying to get clang-4.0 going on my 10.8 (libstdc++) install to see if I can see these myself. Maybe someone else already has this info?

comment:5 Changed 7 years ago by kencu (Ken)

You should see the same errors on all systems that try to build it with clang-4.0+

comment:6 Changed 7 years ago by michaelld (Michael Dickens)

LOL doesn't work on 10.12 for me using libc++. Errors out linking qmake, with the following for 3 different system libraries, just like this ticket #51701 .

I'm getting there with 10.8. Just takes time to get everything installed.

comment:7 Changed 7 years ago by michaelld (Michael Dickens)

It looks like there are just the 2 mentioned comparisons, and I'm happy to use the patches provided by FreeBSD. They look good enough to me. Yes, the ">=" is a little strange, but I think their fix is the correct way to go. I'm testing a patch right now on 10.8 and 10.12.

comment:8 Changed 7 years ago by michaelld (Michael Dickens)

In a12f8d370932d171fef29d833717b07b1b1e742a/macports-ports:

qt4-mac: Fix pointer comparison with 0.

Addresses ticket #54183 .

comment:9 Changed 7 years ago by michaelld (Michael Dickens)

Resolution: fixed
Status: newclosed

Thanks for the "pointer" Ken ... keep them coming!

Note: See TracTickets for help on using tickets.