pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS


corelib: fix FTBS with GCC9
Posted by Anonymous on Thu 10th Sep 2020 07:49
raw | new post

  1. From ea8e7f07321bf7e624086f5b57f0a8d91eadb062 Mon Sep 17 00:00:00 2001
  2. From: Thorsten Scherer <t.scherer@eckelmann.de>
  3. Date: Mon, 4 Nov 2019 17:06:59 +0100
  4. Subject: [PATCH] corelib: fix FTBS with GCC9
  5.  
  6. issue:  ptxdist-2018.11 refused to build reporting lots of errors like
  7.         this one.
  8.  
  9.         qfiledialog.cpp:3158:27: error: 'class Ui_QFileDialog' has no
  10.         member named 'treeView'
  11.  
  12. solution: a patch of debians qt-kde-team
  13.  
  14. url: https://salsa.debian.org/qt-kde-team/qt/qt4-x11/blob/0d4a3dd61ccb156dee556c214dbe91c04d44a717/debian/patches/gcc9-qforeach.patch
  15.  
  16. From c35a3f519007af44c3b364b9af86f6a336f6411b Mon Sep 17 00:00:00 2001
  17. From: Thiago Macieira <thiago.macieira@intel.com>
  18. Date: Tue, 11 Feb 2014 16:17:46 -0800
  19. Subject: [PATCH] Redo the Q_FOREACH loop control without GCC statement
  20.  expressions
  21.  
  22. It's possible to do without them, which probably makes the number of
  23. supported compilers a lot bigger: they just need to support decltype()
  24. or __typeof__.
  25.  
  26. That includes the Intel compiler. The old code was also apparently
  27. working, but no one had realized the old workaround for some old version
  28. was still in place.
  29.  
  30. The loop overhead is more or less the same. I have not done benchmarks,
  31. but inspection of the generated assembly shows more or less the same
  32. number of instructions.
  33.  
  34. Change-Id: I32d499c84a6ddd19d994b49f17a469acb5c3a3f1
  35. Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
  36. Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
  37.  
  38. Backported to Qt 4
  39. ---
  40.  src/corelib/global/qglobal.h | 20 +++++++++++++++-----
  41.  1 file changed, 15 insertions(+), 5 deletions(-)
  42.  
  43. diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
  44. index 20d88328cbcd..34ba4c2d99f3 100644
  45. --- a/src/corelib/global/qglobal.h
  46. +++ b/src/corelib/global/qglobal.h
  47. @@ -2482,22 +2482,32 @@ typedef uint Flags;
  48.  
  49.  #endif /* Q_NO_TYPESAFE_FLAGS */
  50.  
  51. -#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
  52. +#if (defined(Q_CC_GNU) && !defined(Q_CC_RVCT))
  53.  /* make use of typeof-extension */
  54.  template <typename T>
  55.  class QForeachContainer {
  56.  public:
  57. -    inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
  58. +    inline QForeachContainer(const T& t) : c(t), i(c.begin()), e(c.end()), control(1) { }
  59.      const T c;
  60.      int brk;
  61.      typename T::const_iterator i, e;
  62. +    int control;
  63.  };
  64.  
  65. +// Explanation of the control word:
  66. +//  - it's initialized to 1
  67. +//  - that means both the inner and outer loops start
  68. +//  - if there were no breaks, at the end of the inner loop, it's set to 0, which
  69. +//    causes it to exit (the inner loop is run exactly once)
  70. +//  - at the end of the outer loop, it's inverted, so it becomes 1 again, allowing
  71. +//    the outer loop to continue executing
  72. +//  - if there was a break inside the inner loop, it will exit with control still
  73. +//    set to 1; in that case, the outer loop will invert it to 0 and will exit too
  74.  #define Q_FOREACH(variable, container)                                \
  75.  for (QForeachContainer<__typeof__(container)> _container_(container); \
  76. -     !_container_.brk && _container_.i != _container_.e;              \
  77. -     __extension__  ({ ++_container_.brk; ++_container_.i; }))                       \
  78. -    for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
  79. +     _container_.control && _container_.i != _container_.e;         \
  80. +     ++_container_.i, _container_.control ^= 1)                     \
  81. +    for (variable = *_container_.i; _container_.control; _container_.control = 0)
  82.  
  83.  #else
  84.  
  85. --
  86. 2.23.0

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at