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

cannot build with clang++ #64

Open
roblatham00 opened this issue Sep 7, 2017 · 2 comments
Open

cannot build with clang++ #64

roblatham00 opened this issue Sep 7, 2017 · 2 comments

Comments

@roblatham00
Copy link

Trying to compile BwTree with clang++, I get these warnings that don't make a lot of sense to me:

In file included from ./test/main.cpp:2:
In file included from ./test/test_suite.h:20:
./test/../src/bwtree.h:9394:5: error: 'GarbageNode' is a private member of
      'wangziqi2013::bwtree::BwTreeBase'
    GarbageNode *garbage_node_p = \  
    ^
./test/../src/bwtree.h:210:9: note: implicitly declared private here
  class GarbageNode {
        ^
./test/../src/bwtree.h:9395:11: error: 'GarbageNode' is a private member of
      'wangziqi2013::bwtree::BwTreeBase'
      new GarbageNode{GetGlobalEpoch(), (void *)(node_p)};
          ^
./test/../src/bwtree.h:210:9: note: implicitly declared private here
  class GarbageNode {

those declarations look public to me, and trying to mimic your class structure with a small test case did not cause any problems. I clearly oversimplified...

class Foo {
    class Bar {
        public:
            Bar(int a, int b) {}
    };
    void do_stuff() {
        Bar *bar_p = new Bar{5, 10};
    }
};
@wangziqi2013
Copy link
Owner

wangziqi2013 commented Sep 7, 2017

@roblatham00 The problem with Clang is that class GarbageNode is private to all classes that is not a friend of class BwTreeBase, and in the meantime it is accessible by classes defined in class BwTreeBase. This is just like a class's member functions could access its private members, but other non-friend classes could not.

Explicitly declaring class GarbageNode in class BwTreeBase as public could solve the problem.

@mweisgut
Copy link

I had the same issue. Not only GarbageNode but also GC_NODE_COUNT_THREADHOLD and gc_id led to the same errors (... is a private member of 'wangziqi2013::bwtree::BwTreeBase).

A possible quick-and-dirty fix (git diff output):

diff --git a/src/bwtree.h b/src/bwtree.h
index 781a992..3988683 100644
--- a/src/bwtree.h
+++ b/src/bwtree.h
@@ -197,6 +197,7 @@ class BwTreeBase {
   // This is the mask we used for address alignment (AND with this)
   static constexpr size_t CACHE_LINE_MASK = ~(CACHE_LINE_SIZE - 1);
   
+  public:
   // We invoke the GC procedure after this has been reached
   static constexpr size_t GC_NODE_COUNT_THREADHOLD = 1024;
   
@@ -232,6 +233,7 @@ class BwTreeBase {
     {}
   };
   
+  private:
   /*
    * class GCMetaData - Metadata for performing GC on per-thread basis
    */
@@ -305,13 +307,14 @@ class BwTreeBase {
                 "class PaddedGCMetadata size does"
                 " not conform to the alignment!");
  
- private: 
+ public:
   // This is used as the garbage collection ID, and is maintained in a per
   // thread level
   // This is initialized to -1 in order to distinguish between registered 
   // threads and unregistered threads
   static thread_local int gc_id;
   
+  private:
   // This is used to count the number of threads participating GC process
   // We use this number to initialize GC data structure
   static std::atomic<size_t> total_thread_num;

mweisgut added a commit to mweisgut/BwTree that referenced this issue Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants