public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "libin.dang at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug gcov-profile/96919] [GCOV] uncovered line of stack allocation while using virutal destructor
Date: Mon, 26 Oct 2020 07:13:00 +0000 [thread overview]
Message-ID: <bug-96919-4-dasgWvzvRH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96919-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96919
--- Comment #6 from Libin Dang <libin.dang at gmail dot com> ---
(In reply to Martin Liška from comment #2)
> Using latest GCC release you can see what happens:
>
> $ g++ pr96919.cc --coverage && ./a.out && gcov a-pr96919.cc -t
> hello
> libgcov profiling
> error:/home/marxin/Programming/testcases/a-pr96919.gcda:overwriting an
> existing profile data with a different timestamp
> -: 0:Source:pr96919.cc
> -: 0:Graph:a-pr96919.gcno
> -: 0:Data:a-pr96919.gcda
> -: 0:Runs:1
> -: 1:class Base {
> -: 2:public:
> -: 3: Base() = default;
> 1*: 4: virtual ~Base() = default;
> ------------------
> _ZN4BaseD0Ev:
> #####: 4: virtual ~Base() = default;
> ------------------
> _ZN4BaseD2Ev:
> 1: 4: virtual ~Base() = default;
> ------------------
> -: 5: virtual void foo() = 0;
> -: 6:};
> -: 7:class Hello : public Base {
> -: 8:public:
> -: 9: Hello() = default;
> 1*: 10: ~Hello() = default;
> ------------------
> _ZN5HelloD0Ev:
> #####: 10: ~Hello() = default;
> ------------------
> _ZN5HelloD2Ev:
> 1: 10: ~Hello() = default;
> ------------------
> -: 11: void foo() override;
> -: 12:};
> -: 13:
> -: 14:#include <iostream>
> -: 15:
> -: 16:using namespace std;
> -: 17:
> 1: 18:void Hello::foo() {
> 1: 19: cout << "hello" << endl;
> 1: 20:}
> -: 21:
> 1: 22:int main(int argc, char* argv[]) {
> #####: 23: Hello hello;
> 1: 24: hello.foo();
> 1: 25: return 0;
> -: 26:}
>
> So yes, it's a virtual destructor _ZN4BaseD0Ev that is not called.
> And the not executed line:
> #####: 4: Hello hello;
>
> corresponds to a basic block
>
> <bb 5> :
> <L3>:
> Hello::~Hello (&hello);
> resx 2
>
> which would be executed when the Hellow constructor fails.
A strange thing about this test case:
If I removed 'return 0;' at line 25, gcov will mark line 23 as executed.
Tested with both gcov 8.3 and 10.2.
next prev parent reply other threads:[~2020-10-26 7:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-03 13:18 [Bug gcov-profile/96919] New: " youngseok.roh.de at gmail dot com
2020-09-21 11:00 ` [Bug gcov-profile/96919] " marxin at gcc dot gnu.org
2020-09-21 11:05 ` marxin at gcc dot gnu.org
2020-09-28 13:19 ` filip.pudak at gmail dot com
2020-09-29 7:48 ` marxin at gcc dot gnu.org
2020-10-02 11:29 ` marxin at gcc dot gnu.org
2020-10-26 7:13 ` libin.dang at gmail dot com [this message]
2020-10-26 14:55 ` marxin at gcc dot gnu.org
2020-11-17 15:06 ` bhavana.kilambi at blackfigtech dot com
2020-12-02 17:08 ` bhavana.kilambi at blackfigtech dot com
2020-12-02 17:10 ` bhavana.kilambi at blackfigtech dot com
2020-12-03 10:01 ` marxin at gcc dot gnu.org
2020-12-29 9:17 ` bhavana.kilambi at blackfigtech dot com
2021-01-06 11:55 ` marxin at gcc dot gnu.org
2021-01-06 13:55 ` bhavana.kilambi at blackfigtech dot com
2021-01-07 13:27 ` marxin at gcc dot gnu.org
2022-04-21 9:29 ` marxin at gcc dot gnu.org
2023-04-03 9:04 ` marxin at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-96919-4-dasgWvzvRH@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).