summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-07-17 05:48:48 +0000
committerEric Fiselier <eric@efcs.ca>2018-07-17 05:48:48 +0000
commitffbb91bb640b1b0425a91aa70e2a6a2e0f7244e0 (patch)
tree05dc708c199ee13f7a1fd2a6bb33a3841e71a9f7
parent6e089f8b100bb5c118879cf6e1ca935cb89fa259 (diff)
Address "always inline function is not always inlinable" warning with GCC.
When an always_inline function is used prior to the functions definition, the compiler may not be able to inline it as requested by the attribute. GCC flags the `basic_string(CharT const*)` function as one such example. This patch supresses the warning, and the problem, by moving the definition of the string constructor to the inline declaration. This ensures the body is available when it is first ODR used. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@337235 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/string21
1 files changed, 8 insertions, 13 deletions
diff --git a/include/string b/include/string
index 96d36f4f7..162e54058 100644
--- a/include/string
+++ b/include/string
@@ -807,8 +807,14 @@ public:
#endif // _LIBCPP_CXX03_LANG
template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
- _LIBCPP_INLINE_VISIBILITY
- basic_string(const _CharT* __s);
+ _LIBCPP_INLINE_VISIBILITY
+ basic_string(const _CharT* __s) {
+ _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
+ __init(__s, traits_type::length(__s));
+# if _LIBCPP_DEBUG_LEVEL >= 2
+ __get_db()->__insert_c(this);
+# endif
+ }
template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
_LIBCPP_INLINE_VISIBILITY
@@ -1775,17 +1781,6 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
template <class _CharT, class _Traits, class _Allocator>
template <class>
-basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s)
-{
- _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
- __init(__s, traits_type::length(__s));
-#if _LIBCPP_DEBUG_LEVEL >= 2
- __get_db()->__insert_c(this);
-#endif
-}
-
-template <class _CharT, class _Traits, class _Allocator>
-template <class>
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
: __r_(__second_tag(), __a)
{