sinojelly / mockcpp

Two C/C++ testing tools, mockcpp and testngpp.
Apache License 2.0
66 stars 39 forks source link

OutBound 类构造函数初始化值列表存在乱序 #43

Closed fish2bird closed 1 year ago

fish2bird commented 1 year ago

https://github.com/sinojelly/mockcpp/blob/4c2b6d491fff3a8e76801c4b602dc9a55b096423/include/mockcpp/OutBound.h#L33

应该先构造基类,后构造成员,当前会产生编译告警

mockcpp/OutBound.h:53:7: warning: ‘mockcpp::OutBound<pcepEthrpData>::ref’ will be initialized after [-Wreorder]
      T ref;
        ^~~
include/mockcpp/OutBound.h:33:49: warning:   base ‘mockcpp::DecoratedConstraint’ [-Wreorder]
        : ref(val), DecoratedConstraint(constraint)
                      ^

include/mockcpp/OutBound.h:32:5: warning:   when initialized here [-Wreorder]
      OutBound(const T& val, Constraint* constraint = 0)
      ^~~~~~~~
sinojelly commented 1 year ago

如果方便,提个pr解决下?

fish2bird commented 1 year ago

如果方便,提个pr解决下?

已提 PR, 请检视

sinojelly commented 1 year ago

原有用例都能通过?

fish2bird commented 1 year ago

原有用例都能通过?

初始值列表乱序或者正确的顺序,两种场景下编译器生成的指令是完全一样的

https://godbolt.org/z/o8eTe36Go