使用string_view

如何解决使用string_view

我已经编译了以下简单程序:

#include <iostream>
#include <string>
#include <string_view>

using namespace std;

int main(){

    char s[30] = "Hey there!";
    string_view sv(s,7);

    cout<<"s: "<<s<<endl;
    cout<<"sv: "<<sv<<endl;
    return 0;
}

使用以下命令进行编译:

cov-build --dir idir --config /home/d3v/cov-analysis-linux64/config/coverity_config.xml g++ --std=c++17 dev.cpp -o dev

结果显示在控制台上

Coverity Build Capture (64-bit) version 8.7.1 on Linux 3.10.0-514.21.1.el7.x86_64 x86_64
Internal version numbers: a59584cec3 p-lodi1-push-28091.44.570


[WARNING] Emitted 0 C/C++ compilation units (0%) successfully

0 C/C++ compilation units (0%) are ready for analysis
 For more details,please look at: 
    /home/d3v/d3v/idir/build-log.txt

build-log.txt文件的尾巴:

2020-09-14T11:34:00.997198Z|cov-build|19858|info|> Build time (cov-build overall): 00:00:02.288773
2020-09-14T11:34:00.997198Z|cov-build|19858|info|> 
2020-09-14T11:34:00.997678Z|cov-build|19858|info|> Build time (C/C++ emits total): 00:00:00.903396
2020-09-14T11:34:00.997678Z|cov-build|19858|info|> 
2020-09-14T11:34:00.997678Z|cov-build|19858|info|> 
2020-09-14T11:34:00.997725Z|cov-build|19858|info|> [WARNING] Emitted 0 C/C++ compilation units (0%) successfully
2020-09-14T11:34:00.997725Z|cov-build|19858|info|> 
2020-09-14T11:34:00.997725Z|cov-build|19858|info|> 0 C/C++ compilation units (0%) are ready for analysis
2020-09-14T11:34:00.997725Z|cov-build|19858|info|>  For more details,please look at: 
2020-09-14T11:34:00.997725Z|cov-build|19858|info|>     /home/d3v/d3v/idir/build-log.txt

来自buil-log.txt文件的错误:

[STATUS] Compiling dev.cpp
/home/d3v/cov-analysis-linux64/bin/cov-emit --dir=/home/d3v/d3v/idir --ignore_path=/tmp/cov-d3v/891bff16bbd88b7b80d27daaef3e5a81/cov-configure --ignore_path=/tmp/cov-d3v/891bff16bbd88b7b80d27daaef3e5a81/cov-d3v/2d94633aecadf2b164c84654240d09d0 --add_type_modifier=__coverity___fpreg --add_type_modifier=__coverity_decimal --no_predefined_feature_test_macros --no_stdarg_builtin --incompat_proto --no_predefined_cplusplus -w --no_predefines --comp_ver 8.3.1 --char_bit_size=8 --gnu_carriage_return_line_terminator --wchar_t_keyword --no_multiline_string --no_trigraphs --ignore_calling_convention --enable_80bit_float --enable_128bit_float --macro_stack_pragmas --exceptions --arg_dependent_overload --no_predefines --pre_preinclude /home/d3v/d3v/idir/emit/a7f5e15a0c55/config/988f58815e9372b14b5ed84fa4afe3d5/g++-config-0/coverity-macro-compat.h --pre_preinclude /home/d3v/d3v/idir/emit/a7f5e15a0c55/config/988f58815e9372b14b5ed84fa4afe3d5/g++-config-0/coverity-compiler-compat.h --preinclude /home/d3v/cov-analysis-linux64/config/template-g++-config-3/../user_nodefs.h --c++ --allow_incompat_throw --new_array_args --type_traits_helpers --c++14 --gnu_version 80301 --no_trigraphs --sys_include /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8 --sys_include /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux --sys_include /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward --sys_include /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/include --sys_include /usr/local/include --sys_include /opt/rh/devtoolset-8/root/usr/include --sys_include /usr/include -D__NO_INLINE__ --type_sizes=e16Pdlx8fiw4s2 --type_alignments=e16Pdlx8fiw4s2 --size_t_type=m --ptrdiff_t_type=l dev.cpp
"/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../includ
          e/c++/8/type_traits",line 1049: error #255: type name is not allowed
        : public __bool_constant<__is_assignable(_Tp,_Up)>
                                                 ^

"/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../includ
          e/c++/8/type_traits",_Up)>
                                                      ^

"/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../includ
          e/c++/8/type_traits",line 1049: error #20: identifier
          "__is_assignable" is undefined
        : public __bool_constant<__is_assignable(_Tp,_Up)>
                                 ^

"/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../includ
          e/c++/8/type_traits",line 2929: error #255: type name is not allowed
        remove_cv_t<remove_all_extents_t<_Tp>>
        ^

"/opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/../../../../includ
          e/c++/8/type_traits",line 2928: error #20: identifier
          "__has_unique_object_representations" is undefined
      : bool_constant<__has_unique_object_representations(
                      ^

Emit for file '/home/d3v/d3v/dev.cpp' complete.
[ERROR] 5 errors detected in the compilation of "dev.cpp".
WARNING: cov-emit returned with code 1

生成了二进制文件,但是我不明白为什么Coverity报告错误并且cov-emit返回1。请帮助我。

OS:CentOS 7
gcc版本:8.3.1

解决方法

此类错误表明Coverity工具存在问题。 Coverity编译器cov-emit无法编译本机编译器(在本例中为GCC)接受的源代码。因此,它具有某种意想不到的不兼容性。

在这种情况下,我认为主要问题是Coverity版本比编译器要旧,因此缺乏对它的支持。 GCC 8.3 was released in February 2019,而Coverity 8.7 was released in January 2017。对于每个受支持的新编译器版本,Coverity团队可能需要针对该编译器及其捆绑的头文件进行特定的调整。 Coverity文档确切列出了支持的编译器版本。

因此,这提出了两种可能的解决方案:

  1. 使用更新的Coverity版本。
  2. 使用一个较旧的编译器,该版本在Coverity 8.7发布时已经淘汰并得到官方支持。

协会免责声明:我曾经为Coverity / Synopsys工作。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-