https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122759
Bug ID: 122759
Summary: False negative line coverage for first argument of
std::make_shared in multi-line constructor initializer
list
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: n.jeker at gmx dot net
Target Milestone: ---
Reproducer:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/15.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust,cobol
--enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.2.1 20251112 (GCC)
$ cat > test.cpp << 'EOF'
#include <memory>
class A {
public:
A(int a, int b) {}
};
class B {
std::shared_ptr<A> a_shared_correct_;
std::shared_ptr<A> a_shared_wrong_;
public:
B() :
a_shared_correct_(std::make_shared<A>(0, 0)),
a_shared_wrong_(std::make_shared<A>(
0,
0
))
{
}
};
int main(int argc, char** argv) {
B b;
}
EOF
$ g++ --coverage test.cpp -o test
$ ./test
$ gcov test
$ grep -A3 make_shared test.cpp.gcov
1: 14: a_shared_correct_(std::make_shared<A>(0, 0)),
1: 15: a_shared_wrong_(std::make_shared<A>(
#####: 16: 0,
1: 17: 0
-: 18: ))
Expected outcome: All lines of initializer list are hit once (1).
Actual outcome: When splitting the initializer list over multiple lines, line
coverage of the first argument (at line 16) is erroneously reported as #####
(unexecuted).