Re: Clang does not like constexpression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 14-6-2017 20:19, Adam C. Emerson wrote:
> On 14/06/2017, Radoslaw Zarzynski wrote:
>> May we put this somewhere under common/? Although the mentioned
>> Clang build failure has been resolved this morning, I bet the constexpr-
>> capable variant of strlen (ceph::strlen?) will be very useful in the future.
>> Also, I would love to make a clean-up PR based on it.
> 
> Feel free! I didn't know if it would be better if Casey stuck it in his
> string-reserve-join PR, since he has a similar string_length overload,
> or I can make a PR for it later.
> 

Let me resurrect this discussion once more:
// specializations for char*/const char* use strlen()
template <>
struct string_traits<const char*> {
  static constexpr size_t size(const char* s) { return std::strlen(s); }
};

generates:
In file included from
/home/jenkins/workspace/ceph-master/src/test/rgw/test_rgw_string.cc:16:
/home/jenkins/workspace/ceph-master/src/rgw/rgw_string.h:140:27: error:
constexpr function never produces a constant expression
[-Winvalid-constexpr]
  static constexpr size_t size(const char* s) { return std::strlen(s); }
                          ^

--WjW
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux