I've compiled a simple program given below:
#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;
}
Compiled using below command:
cov-build --dir idir --config /home/d3v/cov-analysis-linux64/config/coverity_config.xml g++ --std=c++17 dev.cpp -o dev
Results on to console:
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
tail of build-log.txt file:
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
Error from buil-log.txt file:
[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", 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", 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
Binary was generated, but I'm unable to understand why Coverity is reporting an error and cov-emit
is returning 1. Please help me with this.
OS: CentOS 7
gcc version: 8.3.1
This sort of error indicates a problem in the Coverity tool. The Coverity compiler, cov-emit
, is failing to compile source code that the native compiler (in this case GCC) accepts. Thus, it has some sort of unintended incompatibility.
In this case I think the main issue is the Coverity release is older than the compiler, and hence lacked support for it. GCC 8.3 was released in February 2019, while Coverity 8.7 was released in January 2017. For each new supported compiler release, the Coverity team may need to make adjustments specific to that compiler and its bundled header files. The Coverity documentation lists exactly what compiler versions are supported.
So, that suggests two possible solutions:
Association disclaimer: I used to work for Coverity/Synopsys.