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

在高版本GCC编译的时候 Warning 太多了 #1379

Closed
stdpain opened this issue Apr 14, 2021 · 0 comments · Fixed by #1381
Closed

在高版本GCC编译的时候 Warning 太多了 #1379

stdpain opened this issue Apr 14, 2021 · 0 comments · Fixed by #1381

Comments

@stdpain
Copy link
Contributor

stdpain commented Apr 14, 2021

brpc-0.9.7

bvar/detail/series.h:131:23: warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct bvar::Stat'; use assignment or value-initialization instead [-Wclass-memaccess]
......
include/bvar/detail/percentile.h:240:7: note: 'class bvar::detail::PercentileSamples<254>' declared here
  240 | class PercentileSamples {
      |       ^~~~~~~~~~~~~~~~~
include/bvar/recorder.h:33:8: note: 'struct bvar::Stat' declared here
   33 | struct Stat {

warning太多了,还不太想屏蔽这个warning,请问有patch能修复这个吗

这是我的修改方式,能规避这个warning,但是效率会低一些,有没有官方的patch ?

bvar/detail/series.h line 131

            if (butil::is_integral<T>::value ||                
                  butil::is_floating_point<T>::value) {
                  //memset(_array, 0, sizeof(_array));
                  for(int i = 0;i < sizeof(_array)/sizeof(T);++i) {
                      new(&_array[i])T();
                  }
              }

我看了下rapidjson对于这一类的解决方案是static_cast成 void*
Tencent/rapidjson#1323 官方有考虑做类似的修改吗

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

Successfully merging a pull request may close this issue.

1 participant