You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by GitBox <gi...@apache.org> on 2020/04/21 06:12:06 UTC
[GitHub] [trafficserver] masaori335 opened a new pull request #6692: Fix deprecated-copy warning in cache tool
masaori335 opened a new pull request #6692:
URL: https://github.com/apache/trafficserver/pull/6692
I saw below `-Wdeprecated-copy` warning with llvm-10 on macOS.
```
CXX traffic_cache_tool/traffic_cache_tool-CacheTool.o
traffic_cache_tool/CacheTool.cc:259:5: error: definition of implicit copy constructor for 'V' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
operator=(V const &that)
^
/usr/local/opt/llvm/include/c++/v1/memory:1876:31: note: in implicit copy constructor for 'ct::VolumeAllocator::V' first required here
::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
^
/usr/local/opt/llvm/include/c++/v1/memory:1768:18: note: in instantiation of function template specialization 'std::__1::allocator<ct::VolumeAllocator::V>::construct<ct::VolumeAllocator::V, ct::VolumeAllocator::V>' requested
here
{__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
^
/usr/local/opt/llvm/include/c++/v1/memory:1595:14: note: in instantiation of function template specialization 'std::__1::allocator_traits<std::__1::allocator<ct::VolumeAllocator::V> >::__construct<ct::VolumeAllocator::V, ct::
VolumeAllocator::V>' requested here
{__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
^
/usr/local/opt/llvm/include/c++/v1/vector:924:21: note: in instantiation of function template specialization 'std::__1::allocator_traits<std::__1::allocator<ct::VolumeAllocator::V> >::construct<ct::VolumeAllocator::V, ct::Vol
umeAllocator::V>' requested here
__alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_),
^
/usr/local/opt/llvm/include/c++/v1/vector:1652:9: note: in instantiation of function template specialization 'std::__1::vector<ct::VolumeAllocator::V, std::__1::allocator<ct::VolumeAllocator::V> >::__construct_one_at_end<ct::
VolumeAllocator::V>' requested here
__construct_one_at_end(_VSTD::move(__x));
^
traffic_cache_tool/CacheTool.cc:313:15: note: in instantiation of member function 'std::__1::vector<ct::VolumeAllocator::V, std::__1::allocator<ct::VolumeAllocator::V> >::push_back' requested here
_av.push_back({vol, size, 0, 0});
^
1 error generated.
make[2]: *** [traffic_cache_tool/traffic_cache_tool-CacheTool.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] masaori335 removed a comment on issue #6692: Fix deprecated-copy warning in cache tool
Posted by GitBox <gi...@apache.org>.
masaori335 removed a comment on issue #6692:
URL: https://github.com/apache/trafficserver/pull/6692#issuecomment-617571655
[approve ci ubuntu]
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] ywkaras commented on a change in pull request #6692: Fix deprecated-copy warning in cache tool
Posted by GitBox <gi...@apache.org>.
ywkaras commented on a change in pull request #6692:
URL: https://github.com/apache/trafficserver/pull/6692#discussion_r412242666
##########
File path: src/traffic_cache_tool/CacheTool.cc
##########
@@ -255,6 +255,8 @@ class VolumeAllocator
: _config(config), _size(size), _deficit(deficit), _shares(shares)
{
}
+ V(const V &v) : _config(v._config), _size(v._size), _deficit(v._deficit), _shares(v._shares) {}
Review comment:
Hmm, it seems like this could just be:
```
V(const V &v) = default;
```
But it also seem like you could just let both the copy constructor and the copy assign be defined implicitly. @SolidWallOfCode did you originally write this code, what's the dealio?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] zwoop commented on issue #6692: Fix deprecated-copy warning in cache tool
Posted by GitBox <gi...@apache.org>.
zwoop commented on issue #6692:
URL: https://github.com/apache/trafficserver/pull/6692#issuecomment-618512938
Cherry-picked to 8.1.x
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] masaori335 commented on issue #6692: Fix deprecated-copy warning in cache tool
Posted by GitBox <gi...@apache.org>.
masaori335 commented on issue #6692:
URL: https://github.com/apache/trafficserver/pull/6692#issuecomment-616989592
[approve ci autest]
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] zwoop commented on issue #6692: Fix deprecated-copy warning in cache tool
Posted by GitBox <gi...@apache.org>.
zwoop commented on issue #6692:
URL: https://github.com/apache/trafficserver/pull/6692#issuecomment-618512601
Cherry-picked to v9.0.x branch.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] masaori335 commented on issue #6692: Fix deprecated-copy warning in cache tool
Posted by GitBox <gi...@apache.org>.
masaori335 commented on issue #6692:
URL: https://github.com/apache/trafficserver/pull/6692#issuecomment-617571655
[approve ci ubuntu]
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] masaori335 commented on a change in pull request #6692: Fix deprecated-copy warning in cache tool
Posted by GitBox <gi...@apache.org>.
masaori335 commented on a change in pull request #6692:
URL: https://github.com/apache/trafficserver/pull/6692#discussion_r412563078
##########
File path: src/traffic_cache_tool/CacheTool.cc
##########
@@ -255,6 +255,8 @@ class VolumeAllocator
: _config(config), _size(size), _deficit(deficit), _shares(shares)
{
}
+ V(const V &v) : _config(v._config), _size(v._size), _deficit(v._deficit), _shares(v._shares) {}
Review comment:
Using `= default` and generate copy constructor looks better. Will do.
@SolidWallOfCode will describe better, but if I use the default copy assignment, I got below error.
```
/usr/local/opt/llvm/include/c++/v1/algorithm:3945:17: error: no matching function for call to 'swap'
swap(*__first, *__last);
^~~~
/usr/local/opt/llvm/include/c++/v1/algorithm:4125:12: note: in instantiation of function template specialization 'std::__1::__sort<(lambda at traffic_cache_tool/CacheTool.cc:407:37) &, ct::VolumeAllocator::V *>' requested here
_VSTD::__sort<_Comp_ref>(__first, __last, _Comp_ref(__comp));
^
/usr/local/opt/llvm/include/c++/v1/algorithm:4158:12: note: in instantiation of function template specialization 'std::__1::sort<ct::VolumeAllocator::V *, (lambda at traffic_cache_tool/CacheTool.cc:407:37) &>' requested here
_VSTD::sort<_Tp*, _Comp_ref>(__first.base(), __last.base(), __comp);
^
traffic_cache_tool/CacheTool.cc:407:8: note: in instantiation of function template specialization 'std::__1::sort<ct::VolumeAllocator::V, (lambda at traffic_cache_tool/CacheTool.cc:407:37)>' requested here
std::sort(_av.begin(), _av.end(), [](V const &lhs, V const &rhs) { return lhs._deficit > rhs._deficit; });
^
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] ywkaras commented on a change in pull request #6692: Fix deprecated-copy warning in cache tool
Posted by GitBox <gi...@apache.org>.
ywkaras commented on a change in pull request #6692:
URL: https://github.com/apache/trafficserver/pull/6692#discussion_r413014426
##########
File path: src/traffic_cache_tool/CacheTool.cc
##########
@@ -255,6 +255,8 @@ class VolumeAllocator
: _config(config), _size(size), _deficit(deficit), _shares(shares)
{
}
+ V(const V &v) : _config(v._config), _size(v._size), _deficit(v._deficit), _shares(v._shares) {}
Review comment:
Ah I didn't know an implicit copy assignment isn't defined if any member variables are references.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] masaori335 commented on a change in pull request #6692: Fix deprecated-copy warning in cache tool
Posted by GitBox <gi...@apache.org>.
masaori335 commented on a change in pull request #6692:
URL: https://github.com/apache/trafficserver/pull/6692#discussion_r412563078
##########
File path: src/traffic_cache_tool/CacheTool.cc
##########
@@ -255,6 +255,8 @@ class VolumeAllocator
: _config(config), _size(size), _deficit(deficit), _shares(shares)
{
}
+ V(const V &v) : _config(v._config), _size(v._size), _deficit(v._deficit), _shares(v._shares) {}
Review comment:
Using `= default` and forcing a copy constructor to be generated looks better. Will do.
@SolidWallOfCode will describe better, but if I use the default copy assignment, I got below error.
```
/usr/local/opt/llvm/include/c++/v1/algorithm:3945:17: error: no matching function for call to 'swap'
swap(*__first, *__last);
^~~~
/usr/local/opt/llvm/include/c++/v1/algorithm:4125:12: note: in instantiation of function template specialization 'std::__1::__sort<(lambda at traffic_cache_tool/CacheTool.cc:407:37) &, ct::VolumeAllocator::V *>' requested here
_VSTD::__sort<_Comp_ref>(__first, __last, _Comp_ref(__comp));
^
/usr/local/opt/llvm/include/c++/v1/algorithm:4158:12: note: in instantiation of function template specialization 'std::__1::sort<ct::VolumeAllocator::V *, (lambda at traffic_cache_tool/CacheTool.cc:407:37) &>' requested here
_VSTD::sort<_Tp*, _Comp_ref>(__first.base(), __last.base(), __comp);
^
traffic_cache_tool/CacheTool.cc:407:8: note: in instantiation of function template specialization 'std::__1::sort<ct::VolumeAllocator::V, (lambda at traffic_cache_tool/CacheTool.cc:407:37)>' requested here
std::sort(_av.begin(), _av.end(), [](V const &lhs, V const &rhs) { return lhs._deficit > rhs._deficit; });
^
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] masaori335 removed a comment on issue #6692: Fix deprecated-copy warning in cache tool
Posted by GitBox <gi...@apache.org>.
masaori335 removed a comment on issue #6692:
URL: https://github.com/apache/trafficserver/pull/6692#issuecomment-616989592
[approve ci autest]
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficserver] randall commented on issue #6692: Fix deprecated-copy warning in cache tool
Posted by GitBox <gi...@apache.org>.
randall commented on issue #6692:
URL: https://github.com/apache/trafficserver/pull/6692#issuecomment-617215454
[approve ci autest]
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org