尽管 -isystem 仍生成警告
Posted
技术标签:
【中文标题】尽管 -isystem 仍生成警告【英文标题】:Warnings generated despite -isystem 【发布时间】:2017-05-09 16:33:09 【问题描述】:在编译我们的一个应用程序时,我们使用了 Beast 和 Boost 这两个框架。在 Beast 使用的一些 Boost 代码中,g++ 会生成警告,因为它认为可能存在未初始化的变量。但是,我们使用“-isystem”标志包含 boost 和 beast。这应该会阻止显示警告,但事实并非如此。任何想法为什么?
您可以在下面看到编译命令及其输出,并进行了一些匿名化处理。
/home/user/code/thirdparty/supplier/6.0/sysroots/x86_64-suppliersdk-linux/usr/bin/arm-supplier-linux-gnueabi/arm-supplier-linux-gnueabi-g++ --sysroot=/home/user/code/thirdparty/supplier/6.0/sysroots/armv7a-neon-supplier-linux-gnueabi -DBOOST_ASIO_DISABLE_EPOLL=1 -DEIGEN_MPL2_ONLY -DUSE_LOG -DLOG_THROUGH_SERVERSERVICE=1 -DARM -DNDEBUG -DAPP_TYPE_IS_PT -DOSIRIS_RELEASE_NUMBER=\"0.0\" -DLOGCONFIGFILE=\"app1_dev.log4\" -DCONFIGFILE=\"app1_native.cfg\" -DCONFIGFILE=\"app1_native.cfg\" -DLOGCONFIGFILE=\"app1_dev.log4\" -pthread -std=c++11 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -O2 -ftree-vectorize -ffast-math -Wall -Wextra -Wno-unused-parameter -Wcast-align -Wuninitialized -Wmissing-include-dirs -Wpedantic -I binaryprotocol/include -I common/include -I config/include -I connectivity/include -I core/include -I socketserver/include -isystem /home/user/code/thirdparty/boost/1.64.0/arm/b993705d/include -isystem /home/user/code/thirdparty/log4cplus/1.2.0/arm/b993705d/include -isystem /home/user/code/thirdparty/openssl/1.0.2j/arm/b993705d/include -isystem ../external/common/modernjson -isystem ../external/common/pstreams -isystem ../external/common/beast/include -MD -MF ../osiris-obj/arm/b993705d/mains/app1/TLSWSClient.d -c mains/app1/TLSWSClient.cpp -o ../osiris-obj/arm/b993705d/mains/app1/TLSWSClient.o
In copy constructor ~boost::asio::detail::consuming_buffers<Buffer, Buffers>::consuming_buffers(const boost::asio::detail::consuming_buffers<Buffer, Buffers>&) [with Buffer = boost::asio::const_buffer; Buffers = beast::detail::buffer_cat_helper<beast::http::detail::chunk_encode_delim, boost::asio::null_buffers, boost::asio::const_buffers_1>]~:
cc1plus: warning: ~*((void*)& second +8)~ may be used uninitialized in this function [-Wmaybe-uninitialized]
In file included from /home/user/code/thirdparty/boost/1.64.0/arm/b993705d/include/boost/asio/impl/write.hpp:23:0,
from /home/user/code/thirdparty/boost/1.64.0/arm/b993705d/include/boost/asio/write.hpp:618,
from /home/user/code/thirdparty/boost/1.64.0/arm/b993705d/include/boost/asio/buffered_write_stream.hpp:29,
from /home/user/code/thirdparty/boost/1.64.0/arm/b993705d/include/boost/asio/buffered_stream.hpp:22,
from /home/user/code/thirdparty/boost/1.64.0/arm/b993705d/include/boost/asio.hpp:38,
from ../external/common/beast/include/beast/websocket/stream.hpp:18,
from ../external/common/beast/include/beast/websocket.hpp:14,
from mains/app1/TLSWSClient.h:13,
from mains/app1/TLSWSClient.cpp:11:
/home/user/code/thirdparty/boost/1.64.0/arm/b993705d/include/boost/asio/detail/consuming_buffers.hpp:191:38: note: ~*((void*)& second +8)~ was declared here
typename Buffers::const_iterator second = other.begin_remainder_;
运行 Ubuntu 16.04。供应商提供的g++,其版本如下。
/home/user/code/thirdparty/supplier/6.0/sysroots/x86_64-suppliersdk-linux/usr/bin/arm-supplier-linux-gnueabi/arm-supplier-linux-gnueabi-g++ --version
arm-supplier-linux-gnueabi-g++ (GCC) 5.3.0
【问题讨论】:
【参考方案1】:"-i" 并不总是阻止所有警告。有一段时间,gcc 产生了“可能未初始化”的误报。这看起来就像是那个时代之一。
【讨论】:
哦,好的。谢谢!我无法通过安装新版本的 GCC 来验证这一点,但我会将其标记为正确答案。以上是关于尽管 -isystem 仍生成警告的主要内容,如果未能解决你的问题,请参考以下文章
Cocoa 绑定 - 得到“在键值观察者仍在注册时释放”警告
用户测试中多个客户端的 Symfony 4.4 弃用警告已弃用,但仍存在于文档中