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

Clang compilation errors #80

Closed
lisyarus opened this issue Feb 10, 2014 · 3 comments
Closed

Clang compilation errors #80

lisyarus opened this issue Feb 10, 2014 · 3 comments
Assignees

Comments

@lisyarus
Copy link
Contributor

Compiling with clang-3.3 results in following errors:

In file included from /home/niklis/work/rocksdb/rocksdb/port/port_posix.cc:10:
In file included from /home/niklis/work/rocksdb/rocksdb/./port/port_posix.h:38:
In file included from /usr/include/snappy.h:43:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/string:40:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/char_traits.h:39:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_algobase.h:64:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_pair.h:59:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/move.h:57:
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/type_traits:269:39: error: use of undeclared identifier '__float128'
    struct __is_floating_point_helper<__float128>

The same bug is reported here:
http://llvm.org/bugs/show_bug.cgi?id=13530

Changing -std=gnu++11 to -std=c++11 seems to fix it.

In file included from /home/niklis/work/rocksdb/rocksdb/util/statistics.cc:6:
In file included from /home/niklis/work/rocksdb/rocksdb/./util/statistics.h:7:
In file included from /home/niklis/work/rocksdb/rocksdb/include/rocksdb/statistics.h:13:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/string:40:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/char_traits.h:39:
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_algobase.h:739:11: error: overload resolution selected deleted operator '='
        *__first = __value;
        ~~~~~~~~ ^ ~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_algobase.h:786:23: note: in instantiation of function template specialization 'std::__fill_n_a<std::__atomic_base<unsigned long> *,
      unsigned long, std::__atomic_base<unsigned long> >' requested here
      return _OI(std::__fill_n_a(std::__niter_base(__first), __n, __value));
                      ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_uninitialized.h:515:9: note: in instantiation of function template specialization 'std::fill_n<std::__atomic_base<unsigned long> *,
      unsigned long, std::__atomic_base<unsigned long> >' requested here
          std::fill_n(__first, __n, _ValueType());
               ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_uninitialized.h:544:2: note: in instantiation of function template specialization
      'std::__uninitialized_default_n_1<true>::__uninit_default_n<std::__atomic_base<unsigned long> *, unsigned long>' requested here
        __uninit_default_n(__first, __n);
        ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_uninitialized.h:605:12: note: in instantiation of function template specialization
      'std::__uninitialized_default_n<std::__atomic_base<unsigned long> *, unsigned long>' requested here
    { std::__uninitialized_default_n(__first, __n); }
           ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:1224:7: note: in instantiation of function template specialization
      'std::__uninitialized_default_n_a<std::__atomic_base<unsigned long> *, unsigned long, std::__atomic_base<unsigned long> >' requested here
        std::__uninitialized_default_n_a(this->_M_impl._M_start, __n, 
             ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:271:9: note: in instantiation of member function 'std::vector<std::__atomic_base<unsigned long>,
      std::allocator<std::__atomic_base<unsigned long> > >::_M_default_initialize' requested here
      { _M_default_initialize(__n); }
        ^
/home/niklis/work/rocksdb/rocksdb/util/statistics.cc:18:7: note: in instantiation of member function 'std::vector<std::__atomic_base<unsigned long>, std::allocator<std::__atomic_base<unsigned long> >
      >::vector' requested here
    : tickers_(TICKER_ENUM_MAX),
      ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/atomic_base.h:360:22: note: candidate function has been explicitly deleted
      __atomic_base& operator=(const __atomic_base&) = delete;
                     ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/atomic_base.h:361:22: note: candidate function has been explicitly deleted
      __atomic_base& operator=(const __atomic_base&) volatile = delete;
                     ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/atomic_base.h:373:7: note: candidate function
      operator=(__int_type __i) noexcept
      ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/atomic_base.h:380:7: note: candidate function
      operator=(__int_type __i) volatile noexcept

This seems to be a well-known bug in the c++ standard library:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58982

A workaround was found that fixes that and works in both gcc-4.8 and clang-3.3:

diff --git a/util/statistics.cc b/util/statistics.cc
index f86eb2c..53ea239 100644
--- a/util/statistics.cc
+++ b/util/statistics.cc
@@ -15,8 +15,7 @@ std::shared_ptr<Statistics> CreateDBStatistics() {
 }

 StatisticsImpl::StatisticsImpl()
-    : tickers_(TICKER_ENUM_MAX),
-      histograms_(HISTOGRAM_ENUM_MAX) {}
+    : histograms_(HISTOGRAM_ENUM_MAX) {}

 StatisticsImpl::~StatisticsImpl() {}

diff --git a/util/statistics.h b/util/statistics.h
index f598bdb..fa43c9e 100644
--- a/util/statistics.h
+++ b/util/statistics.h
@@ -10,6 +10,7 @@

 #include <vector>
 #include <atomic>
+#include <array>

 #define UNLIKELY(val) (__builtin_expect((val), 0))

@@ -28,7 +29,7 @@ class StatisticsImpl : public Statistics {
                              HistogramData* const data);

  private:
-  std::vector<std::atomic_uint_fast64_t> tickers_;
+  std::array<std::atomic_uint_fast64_t, TICKER_ENUM_MAX> tickers_;
   std::vector<HistogramImpl> histograms_;
 };

/home/niklis/work/rocksdb/rocksdb/db/table_properties_collector_test.cc:137:14: error: chosen constructor is explicit in copy-initialization
      return {};
             ^~
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/unordered_map.h:138:7: note: constructor declared here
      unordered_map(size_type __n = 10,
      ^

This std::unordered_map constructor is declared explicit. A patch that makes this compile:

diff --git a/db/table_properties_collector_test.cc b/db/table_properties_collector_test.cc
index 6f405b2..cdc373e 100644
--- a/db/table_properties_collector_test.cc
+++ b/db/table_properties_collector_test.cc
@@ -134,7 +134,7 @@ class RegularKeysStartWithA: public TablePropertiesCollector {

   virtual TableProperties::UserCollectedProperties
     GetReadableProperties() const {
-      return {};
+      return TableProperties::UserCollectedProperties {};
   }


igorcanadi added a commit that referenced this issue Feb 10, 2014
Summary:
Looks like gnu++11 is not very portable (see #80). We don't (yet) depend on any extensions of gnu++11, so I think we should switch back to c++11.

More on this topic here: http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Extensions.html

Test Plan: make check works :)

Reviewers: kailiu, dhruba, haobo

Reviewed By: kailiu

CC: leveldb

Differential Revision: https://reviews.facebook.net/D16053
@igorcanadi
Copy link
Collaborator

(1) is fixed
(2) should already be fixed in the master branch. can you confirm?
(3) cc @liukai

@lisyarus
Copy link
Contributor Author

Yes, 2nd case seems to be fixed in master.

@liukai
Copy link
Contributor

liukai commented Feb 12, 2014

I use clang 5.0 MacOS but didn't reproduce it (but I do saw that problem in some other platform).

I'll submit a diff to fix #3 soon.

liukai added a commit that referenced this issue Feb 12, 2014
petermattis pushed a commit to petermattis/rocksdb that referenced this issue May 1, 2020
util/channel.h: remove an invalid const specifier
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