Fix compilation with clang
AbandonedPublic

Authored by aacid on Oct 13 2019, 12:32 AM.

Details

Reviewers
the
Summary

Diff Detail

Repository
R347 KWave
Branch
Applications/19.08
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 17633
Build 17651: arc lint + arc unit
aacid requested review of this revision.Oct 13 2019, 12:32 AM
aacid created this revision.
the requested changes to this revision.Fri, Oct 18, 12:40 PM

sorry, but I have to reject this change, it is definitly a bug in clang-9. Why shall a parameter that uses QList<unsigned int> be a "private" element? This makes no sense. It seems that clang does not take into account that QList is a template and has template parameters - the place where it is used is a class that has a parent which has a parent that also is a QList<...>, but a QList of a different type.

However, this made me reconsider using a QList<unsigned int> for a list of numbers, which might not be a good choice. I changed that to QVector<unsigned int> which IMHO fits better.

-> obsoleted by git commit ae4027d640d3

This revision now requires changes to proceed.Fri, Oct 18, 12:40 PM
aacid added a comment.Sun, Oct 20, 5:16 PM

It's not a bug in clang, it's how C++ works, but hey, whatever

Commit ae4027d640d3297e78d8d0c87389aade128476a5 fixes the problem in a different way, by changing QList<T> parameters to QVector<T>.

The original problem is, as @aacid says, the way C++ works (and not a clang 9 bug; more that earlier clang and gcc shouldn't accept it in the first place):

  • class MultiTrackSource<SOURCE, INITIALIZE> inherits privately from QList<SOURCE*>. The commit mentioned above didn't change that.
  • When inheriting privately from T, the name T is available in that class. But in subclasses, whatever their inheritance, the name T is not private. The example below (which I also put in the FreeBSD review) shows how that works.
  • Now (in master), the name QList is not used in any context that inherits from MultiTrackSource. So it compiles. And as long as you don't use a QList in those contexts, it'll be fine.

The example given elsewhere (and on StackOverflow, as @aacid also pointed out):

// For QList: this is obviously public
struct foo {}; 
// For MultiTrackSource, **privately** inheriting the public QList
struct bar : private foo {};
// For MultiTrackWriter, publicly inheriting MultiTrackSource, but here
// .. QList is now hidden as a **name** by the private inheritance in MultiTrackSource.
struct baz : public bar {
  // Declaration of func() using QList parameters causes a compile error
  // .. because QList is private **in this context** as a name. That's why
  // .. re-anchoring the name lookup (as @aacid and I did in patches) works,
  // .. because the public name is found rather than the private name.
  void func( foo& );
};

(also change is obsolete and should be abandoned)

aacid abandoned this revision.Sun, Oct 20, 10:03 PM