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

common/iso_8601.cc: Make return expression Clang compatible #15336

Merged
merged 1 commit into from May 28, 2017

Conversation

Projects
None yet
3 participants
@wjwithagen
Copy link
Contributor

wjwithagen commented May 27, 2017

Signed-off-by: Willem Jan Withagen wjw@digiware.nl

common/iso_8601.cc: Make return expression Clang compatible
Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>

@wjwithagen wjwithagen requested a review from tchaikov May 27, 2017

@tchaikov tchaikov requested a review from adamemerson May 27, 2017

@tchaikov

This comment has been minimized.

Copy link
Contributor

tchaikov commented May 27, 2017

@wjwithagen could you paste the error message?

@wjwithagen

This comment has been minimized.

Copy link
Contributor Author

wjwithagen commented May 27, 2017

@tchaikov

[ 43%] Building CXX object src/CMakeFiles/common-objs.dir/common/iso_8601.cc.o
/home/wjw/Ceph/work/ceph/src/common/iso_8601.cc:44:10: error: no viable conversion from returned
      value of type 'time_point<ceph::time_detail::real_clock, typename common_type<duration<unsigned
      long, ratio<1, 1000000000> >, duration<long long, ratio<1, 1000000000> > >::type>' (aka
      'time_point<ceph::time_detail::real_clock, duration<unsigned long long,
      ratio<__static_gcd<ratio<1, 1000000000>::num, ratio<1, 1000000000>::num>::value,
      __static_lcm<ratio<1, 1000000000>::den, ratio<1, 1000000000>::den>::value> > >') to function
      return type 'optional<real_time>' (aka 'optional<time_point<ceph::time_detail::real_clock> >')
  return real_clock::from_time_t(tt) + nanoseconds(n);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/optional/optional.hpp:796:5: note: candidate constructor not viable: no
      known conversion from 'time_point<ceph::time_detail::real_clock, typename
      common_type<duration<unsigned long, ratio<1, 1000000000> >, duration<long long, ratio<1,
      1000000000> > >::type>' (aka 'time_point<ceph::time_detail::real_clock, duration<unsigned long
      long, ratio<__static_gcd<ratio<1, 1000000000>::num, ratio<1, 1000000000>::num>::value,
      __static_lcm<ratio<1, 1000000000>::den, ratio<1, 1000000000>::den>::value> > >') to
      'boost::none_t' for 1st argument
    optional( none_t none_ ) BOOST_NOEXCEPT : base(none_) {}
    ^
/usr/local/include/boost/optional/optional.hpp:800:5: note: candidate constructor not viable: no
      known conversion from 'time_point<ceph::time_detail::real_clock, typename
      common_type<duration<unsigned long, ratio<1, 1000000000> >, duration<long long, ratio<1,
      1000000000> > >::type>' (aka 'time_point<ceph::time_detail::real_clock, duration<unsigned long
      long, ratio<__static_gcd<ratio<1, 1000000000>::num, ratio<1, 1000000000>::num>::value,
      __static_lcm<ratio<1, 1000000000>::den, ratio<1, 1000000000>::den>::value> > >') to
      'argument_type' (aka 'const std::__1::chrono::time_point<ceph::time_detail::real_clock,
      std::__1::chrono::duration<unsigned long, std::__1::ratio<1, 1000000000> > > &') for 1st
      argument
/usr/local/include/boost/optional/optional.hpp:805:5: note: candidate constructor not viable: no
      known conversion from 'time_point<ceph::time_detail::real_clock, typename
      common_type<duration<unsigned long, ratio<1, 1000000000> >, duration<long long, ratio<1,
      1000000000> > >::type>' (aka 'time_point<ceph::time_detail::real_clock, duration<unsigned long
      long, ratio<__static_gcd<ratio<1, 1000000000>::num, ratio<1, 1000000000>::num>::value,
      __static_lcm<ratio<1, 1000000000>::den, ratio<1, 1000000000>::den>::value> > >') to
      'rval_reference_type' (aka 'std::__1::chrono::time_point<ceph::time_detail::real_clock,
      std::__1::chrono::duration<unsigned long, std::__1::ratio<1, 1000000000> > > &&') for 1st
      argument
    optional ( rval_reference_type val ) : base( boost::forward<T>(val) )
    ^
/usr/local/include/boost/optional/optional.hpp:877:5: note: candidate constructor not viable: no
      known conversion from 'time_point<ceph::time_detail::real_clock, typename
      common_type<duration<unsigned long, ratio<1, 1000000000> >, duration<long long, ratio<1,
      1000000000> > >::type>' (aka 'time_point<ceph::time_detail::real_clock, duration<unsigned long
      long, ratio<__static_gcd<ratio<1, 1000000000>::num, ratio<1, 1000000000>::num>::value,
      __static_lcm<ratio<1, 1000000000>::den, ratio<1, 1000000000>::den>::value> > >') to 'const
      boost::optional<std::__1::chrono::time_point<ceph::time_detail::real_clock,
      std::__1::chrono::duration<unsigned long, std::__1::ratio<1, 1000000000> > > > &' for 1st
      argument
    optional ( optional const& rhs ) : base( static_cast<base const&>(rhs) ) {}
    ^
/usr/local/include/boost/optional/optional.hpp:882:2: note: candidate constructor not viable: no
      known conversion from 'time_point<ceph::time_detail::real_clock, typename
      common_type<duration<unsigned long, ratio<1, 1000000000> >, duration<long long, ratio<1,
      1000000000> > >::type>' (aka 'time_point<ceph::time_detail::real_clock, duration<unsigned long
      long, ratio<__static_gcd<ratio<1, 1000000000>::num, ratio<1, 1000000000>::num>::value,
      __static_lcm<ratio<1, 1000000000>::den, ratio<1, 1000000000>::den>::value> > >') to
      'boost::optional<std::__1::chrono::time_point<ceph::time_detail::real_clock,
      std::__1::chrono::duration<unsigned long, std::__1::ratio<1, 1000000000> > > > &&' for 1st
      argument
        optional ( optional && rhs )
        ^
1 error generated.
@adamemerson
Copy link
Contributor

adamemerson left a comment

Linguistic Gematria Traces Meaning

@@ -41,7 +41,8 @@ optional<real_time> calculate(const tm& t, uint32_t n = 0) {
return none;
}

return real_clock::from_time_t(tt) + nanoseconds(n);
return boost::make_optional<real_time>(real_clock::from_time_t(tt)
+ nanoseconds(n));
}

This comment has been minimized.

Copy link
@adamemerson

adamemerson May 27, 2017

Contributor

This looks fine. If it works I'd rather use something like

  return { real_clock::from_time_t(tt) + nanoseconds(n) };

Since that will continue to work if we switch to std::optional, but it's by no means necessary.

This comment has been minimized.

Copy link
@wjwithagen

wjwithagen May 28, 2017

Author Contributor

@adamemerson
Not really, as far as Clang is concerned:

[ 43%] Building CXX object src/CMakeFiles/common-objs.dir/common/iso_8601.cc.o
/home/wjw/Ceph/work/ceph/src/common/iso_8601.cc:46:10: error: chosen constructor is explicit in
      copy-initialization
  return { real_clock::from_time_t(tt) + nanoseconds(n) };
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This comment has been minimized.

Copy link
@tchaikov

tchaikov May 28, 2017

Contributor

@wjwithagen you are using the boost in FreeBSD port, aren't you? probably that's why it fails to build in your env, but not in ours. a wild guess =)

This comment has been minimized.

Copy link
@wjwithagen

wjwithagen May 28, 2017

Author Contributor

@tchaikov
That could very well be the case. My system Boost is at version 1.64.

@tchaikov
Copy link
Contributor

tchaikov left a comment

strange enough, i tested

#include <boost/optional.hpp>

struct Foo {
  static Foo make_foo() {
    return Foo();
  }
};
boost::optional<Foo> calculate() {
  return Foo::make_foo();
}

int main() {
  calculate();
}

using clang 4.0. and it compiles .

@wjwithagen

This comment has been minimized.

Copy link
Contributor Author

wjwithagen commented May 28, 2017

@tchaikov
I'm using Clang 3.8 3,9 on FreeBSD 11, the most current release
and 4.0 on FreeBSD 12 that is the development version.
But my 4.0 does exhibit the error, so it might even depend on the actual revision.

@tchaikov tchaikov merged commit 0d3e6a9 into ceph:master May 28, 2017

3 checks passed

Signed-off-by all commits in this PR are signed
Details
Unmodifed Submodules submodules for project are unmodified
Details
default Build finished.
Details

@wjwithagen wjwithagen deleted the wjwithagen:wjw-wip-iso_8601 branch Jan 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.