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

许多编译警报 #546

Closed
choleraehyq opened this issue Oct 25, 2018 · 7 comments
Closed

许多编译警报 #546

choleraehyq opened this issue Oct 25, 2018 · 7 comments
Labels
wontfix Not belonging to other labels

Comments

@choleraehyq
Copy link
Contributor

choleraehyq commented Oct 25, 2018

Describe the bug (描述bug)
A clear and concise description of what the bug is. 请准确描述bug是什么.
许多编译警报

In file included from brpc/examples/grpc/main.cc:1:0:
brpc/include/butil/logging.h:417:7: error: 'class logging::VLogSitePrinter' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
 class VLogSitePrinter {
       ^
In file included from brpc/include/brpc/controller.h:34:0,
                 from brpc/include/brpc/server.h:33,
                 from brpc/examples/grpc/main.cc:2:
brpc/include/brpc/stream.h:38:7: error: 'class brpc::StreamInputHandler' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
 class StreamInputHandler {
       ^
In file included from brpc/include/brpc/controller.h:35:0,
                 from brpc/include/brpc/server.h:33,
                 from brpc/examples/grpc/main.cc:2:
brpc/include/brpc/stream_creator.h:29:7: error: 'class brpc::StreamCreator' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
 class StreamCreator {
       ^
brpc/include/brpc/stream_creator.h:57:7: error: 'class brpc::StreamUserData' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
 class StreamUserData {
       ^
In file included from brpc/include/brpc/server.h:37:0,
                 from brpc/examples/grpc/main.cc:2:
brpc/include/brpc/builtin/tabbed.h:77:7: error: 'class brpc::Tabbed' has virtual functions and accessible non-virtual destructor [-Werror=non-virtual-dtor]
 class Tabbed {
       ^
In file included from brpc/include/butil/logging.h:29:0,
                 from brpc/examples/grpc/main.cc:1:
brpc/include/bvar/detail/percentile.h: In instantiation of 'void bvar::detail::PercentileInterval<SAMPLE_SIZE>::merge(const bvar::detail::PercentileInterval<size2>&) [with long unsigned int size2 = 254ul; long unsigned int SAMPLE_SIZE = 254ul]':
brpc/include/bvar/detail/percentile.h:320:17:   required from 'void bvar::detail::PercentileSamples<SAMPLE_SIZE_IN>::merge(const bvar::detail::PercentileSamples<size2>&) [with long unsigned int size2 = 254ul; long unsigned int SAMPLE_SIZE_IN = 254ul]'
brpc/include/bvar/detail/percentile.h:452:13:   required from 'void bvar::detail::Percentile::AddPercentileSamples::operator()(bvar::detail::PercentileSamples<size>&, const bvar::detail::PercentileSamples<size2>&) const [with long unsigned int size1 = 254ul; long unsigned int size2 = 254ul]'
brpc/include/bvar/detail/sampler.h:165:53:   required from 'bool bvar::detail::ReducerSampler<R, T, Op, InvOp>::get_value(time_t, bvar::detail::Sample<T>*) [with R = bvar::detail::Percentile; T = bvar::detail::PercentileSamples<254ul>; Op = bvar::detail::Percentile::AddPercentileSamples; InvOp = bvar::detail::VoidOp; time_t = long int]'
brpc/include/bvar/window.h:94:55:   required from 'bool bvar::detail::WindowBase<R, series_freq>::get_span(time_t, bvar::detail::Sample<typename R::value_type>*) const [with R = bvar::detail::Percentile; bvar::SeriesFrequency series_freq = (bvar::SeriesFrequency)1u; time_t = long int; typename R::value_type = bvar::detail::PercentileSamples<254ul>]'
brpc/include/bvar/window.h:103:39:   required from 'bvar::detail::WindowBase<R, series_freq>::value_type bvar::detail::WindowBase<R, series_freq>::get_value(time_t) const [with R = bvar::detail::Percentile; bvar::SeriesFrequency series_freq = (bvar::SeriesFrequency)1u; bvar::detail::WindowBase<R, series_freq>::value_type = bvar::detail::PercentileSamples<254ul>; time_t = long int]'
brpc/include/butil/iobuf.h:475:7:   required from here
brpc/include/bvar/detail/percentile.h:127:42: error: variable length array is used [-Werror=vla]
             DEFINE_SMALL_ARRAY(uint32_t, tmp, rhs._num_samples, 64);
                                          ^
brpc/include/butil/macros.h:374:8: note: in definition of macro 'DEFINE_SMALL_ARRAY'
     Tp name##_stack_array[name##_stack_array_size];                     \
        ^
cc1plus: all warnings being treated as errors

To Reproduce (复现方法)
Please describe the steps to reproduce the behavior. 请描述复现问题的步骤.
编译 grpc example,使用了公司内部编译工具,没法描述步骤,但是警报很清楚,跟编译步骤应该没啥关系

Expected behavior (期望行为)
A clear and concise description of what you expected to happen. 请准确描述你期望发生什么.
编译通过
Versions (各种版本)
OS: 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 GNU/Linux
Compiler: g++ 4.9.2, -std=c++1y -Wall -Werror -Wextra
brpc: 2d781de
protobuf: 3.6.0

Additional context (更多上下文)
Add any other context or screenshots here. 这里添加更多上下文或截图.

@jamesge
Copy link
Contributor

jamesge commented Oct 26, 2018

编译打开-pedantic了么

@choleraehyq
Copy link
Contributor Author

打开 -pedantic 报了更多的编译警报,比如这种:

brpc/include/butil/containers/hash_tables.h:187:41: error: extra ';' [-Werror=pedantic]
 DEFINE_32BIT_PAIR_HASH(int16_t, int16_t);
                                         ^
brpc/include/butil/containers/hash_tables.h:188:42: error: extra ';' [-Werror=pedantic]
 DEFINE_32BIT_PAIR_HASH(int16_t, uint16_t);
                                          ^
brpc/include/butil/containers/hash_tables.h:189:41: error: extra ';' [-Werror=pedantic]
 DEFINE_32BIT_PAIR_HASH(int16_t, int32_t);
                                         ^
brpc/include/butil/containers/hash_tables.h:190:42: error: extra ';' [-Werror=pedantic]
 DEFINE_32BIT_PAIR_HASH(int16_t, uint32_t);
                                          ^
brpc/include/butil/containers/hash_tables.h:191:42: error: extra ';' [-Werror=pedantic]
 DEFINE_32BIT_PAIR_HASH(uint16_t, int16_t);
                                          ^
brpc/include/butil/containers/hash_tables.h:192:43: error: extra ';' [-Werror=pedantic]

@jamesge
Copy link
Contributor

jamesge commented Oct 26, 2018

-pedantic是不用加的,这是以更严格的标准来检查代码。我是确认下没加。这儿的warning看起来确实是正确的warning,但在C++0x下没报,我们会看一下c++14和c++1y下的编译问题。

@zyearn
Copy link
Member

zyearn commented Oct 26, 2018

@choleraehyq 你们的g++自己改过么,开了你的option,试了g++4.8和g++7,只有在显式delete有non-virtual-dtor的基类指针的时候,才会报上面的warning,而brpc里面没有显式的delete你帖出来的StreamCreator和StreamUserData的基类指针,所以在我本地就没有报warning

@choleraehyq
Copy link
Contributor Author

choleraehyq commented Oct 26, 2018

@zyearn
是 4.9.2,不过是 debian 维护的 g++ 包

g++ (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@ibyte2011
Copy link
Contributor

这个问题有解决办法了吗?Centos-7.4.1708 g++4.8 std=c++11 编译遇到同样的问题。

@stale
Copy link

stale bot commented Dec 7, 2018

This issue has been automatically marked as stale because it's inactive for a long time. It will be closed if no further activity occurs, reopen if you have further ideas. Thank you for your contributions! 由于很久没有活跃,此Issue已被自动标记为过期。之后几天仍无变化的话将会被关闭,若你有新想法则可重新打开。感谢你的贡献!

@stale stale bot added the wontfix Not belonging to other labels label Dec 7, 2018
@stale stale bot closed this as completed Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix Not belonging to other labels
Projects
None yet
Development

No branches or pull requests

4 participants