public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12076] New: gcov misreports coverage of return statement
@ 2003-08-27  9:34 r dot lichtenberger at icoserve dot com
  2003-08-27 14:05 ` [Bug c++/12076] " bangerth at dealii dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: r dot lichtenberger at icoserve dot com @ 2003-08-27  9:34 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076

           Summary: gcov misreports coverage of return statement
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: r dot lichtenberger at icoserve dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

I compiled & ran this little program:
#include <string>
#include <iostream>

std::string repeat(const std::string& p_str, unsigned int p_count)
{
    std::string result;
    for (unsigned int i=0;i<p_count;++i)
        result+=p_str;
    return result;
}

int main(void)
{
        std::cout << repeat("gnu", 20) << std::endl;

        return 0;
}

The line containing the return statement is marked as "not run", which cannot be:
                std::string repeat(const std::string& p_str, unsigned int p_count)
           1    {
           1        std::string result;
          21        for (unsigned int i=0;i<p_count;++i)
          20            result+=p_str;
      ######        return result;
                }


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12076] gcov misreports coverage of return statement
  2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
@ 2003-08-27 14:05 ` bangerth at dealii dot org
  2003-11-28  8:02 ` [Bug other/12076] gcov misreports coverage of return statement (for inline functions) pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: bangerth at dealii dot org @ 2003-08-27 14:05 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-08-27 14:05:00
               date|                            |


------- Additional Comments From bangerth at dealii dot org  2003-08-27 14:04 -------
Confirmed up to present mainline. 
W.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug other/12076] gcov misreports coverage of return statement (for inline functions)
  2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
  2003-08-27 14:05 ` [Bug c++/12076] " bangerth at dealii dot org
@ 2003-11-28  8:02 ` pinskia at gcc dot gnu dot org
  2003-11-28  9:11 ` r dot lichtenberger at icoserve dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-11-28  8:02 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-11-28 08:02 -------
The problem at -O3, gcc inlines more functions and in this case repeat is inlined so the 
return is misreported because really is not executed at all (it is a no-op).  I  going to say 
this is a non-bug because it really is not executed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID
            Summary|gcov misreports coverage of |gcov misreports coverage of
                   |return statement            |return statement (for inline
                   |                            |functions)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug other/12076] gcov misreports coverage of return statement (for inline functions)
  2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
  2003-08-27 14:05 ` [Bug c++/12076] " bangerth at dealii dot org
  2003-11-28  8:02 ` [Bug other/12076] gcov misreports coverage of return statement (for inline functions) pinskia at gcc dot gnu dot org
@ 2003-11-28  9:11 ` r dot lichtenberger at icoserve dot com
  2003-11-28 17:47 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: r dot lichtenberger at icoserve dot com @ 2003-11-28  9:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From r dot lichtenberger at icoserve dot com  2003-11-28 09:11 -------
But the problem also occurs when using -O0 (no optimization). Here is how I
compiled:
[tanis@icotanis new]$ g++ -fprofile-arcs -ftest-coverage -O0 covtest.cc 

With -O0, the compiler should not inline, should it?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |
            Version|3.2.2                       |3.2.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug other/12076] gcov misreports coverage of return statement (for inline functions)
  2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
                   ` (2 preceding siblings ...)
  2003-11-28  9:11 ` r dot lichtenberger at icoserve dot com
@ 2003-11-28 17:47 ` pinskia at gcc dot gnu dot org
  2003-12-01  6:27 ` r dot lichtenberger at icoserve dot com
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-11-28 17:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-11-28 17:47 -------
I can confirm this at -O0 but it works correctly at -O1.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |NEW


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug other/12076] gcov misreports coverage of return statement (for inline functions)
  2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
                   ` (3 preceding siblings ...)
  2003-11-28 17:47 ` pinskia at gcc dot gnu dot org
@ 2003-12-01  6:27 ` r dot lichtenberger at icoserve dot com
  2003-12-01  6:33 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: r dot lichtenberger at icoserve dot com @ 2003-12-01  6:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From r dot lichtenberger at icoserve dot com  2003-12-01 06:27 -------
Which version did you use? With this version:
  [tanis@icotanis new]$ g++ --version
  g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-20)

-O1 is no different. 



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug other/12076] gcov misreports coverage of return statement (for inline functions)
  2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
                   ` (4 preceding siblings ...)
  2003-12-01  6:27 ` r dot lichtenberger at icoserve dot com
@ 2003-12-01  6:33 ` pinskia at gcc dot gnu dot org
  2003-12-26 23:11 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-01  6:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-01 06:33 -------
The mainline (3.4 20031108).

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug other/12076] gcov misreports coverage of return statement (for inline functions)
  2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
                   ` (5 preceding siblings ...)
  2003-12-01  6:33 ` pinskia at gcc dot gnu dot org
@ 2003-12-26 23:11 ` pinskia at gcc dot gnu dot org
  2004-05-21 21:52 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-12-26 23:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-12-26 23:01 -------
Very much related to bug 11773.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug other/12076] gcov misreports coverage of return statement (for inline functions)
  2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
                   ` (6 preceding siblings ...)
  2003-12-26 23:11 ` pinskia at gcc dot gnu dot org
@ 2004-05-21 21:52 ` pinskia at gcc dot gnu dot org
  2004-08-13  0:04 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-21 21:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-20 20:23 -------
Actually this has to do with deconstrutors so I do not think this is a bug.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug other/12076] gcov misreports coverage of return statement (for inline functions)
  2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
                   ` (7 preceding siblings ...)
  2004-05-21 21:52 ` pinskia at gcc dot gnu dot org
@ 2004-08-13  0:04 ` pinskia at gcc dot gnu dot org
  2005-07-25  1:52 ` [Bug c++/12076] gcov misreports coverage of return statement [NVR] pinskia at gcc dot gnu dot org
  2005-07-25 21:04 ` jbuck at gcc dot gnu dot org
  10 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-13  0:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-13 00:04 -------
I know what the bug is really, it has to do with NVR optimization in GCC which allows the return value 
to at the same location as result.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12076] gcov misreports coverage of return statement [NVR]
  2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
                   ` (8 preceding siblings ...)
  2004-08-13  0:04 ` pinskia at gcc dot gnu dot org
@ 2005-07-25  1:52 ` pinskia at gcc dot gnu dot org
  2005-07-25 21:04 ` jbuck at gcc dot gnu dot org
  10 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-25  1:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-25 01:43 -------
*** Bug 23052 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jbuck at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12076] gcov misreports coverage of return statement [NVR]
  2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
                   ` (9 preceding siblings ...)
  2005-07-25  1:52 ` [Bug c++/12076] gcov misreports coverage of return statement [NVR] pinskia at gcc dot gnu dot org
@ 2005-07-25 21:04 ` jbuck at gcc dot gnu dot org
  10 siblings, 0 replies; 14+ messages in thread
From: jbuck at gcc dot gnu dot org @ 2005-07-25 21:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jbuck at gcc dot gnu dot org  2005-07-25 20:54 -------
It's OK if NVR uses the same location and emits no code, and if coverage
information reflects this.  The problem is that part of the coverage machinery
appears to "think" that there is unreached code on the line with the return
statement, so a "#####" is output rather than a "-".  Emitting a "-" rather
than a count would also be OK, and arguably correct if there is no real object
code corresponding to the source line.





-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12076] gcov misreports coverage of return statement [NVR]
       [not found] <bug-12076-6823@http.gcc.gnu.org/bugzilla/>
  2005-10-27  1:41 ` reddy at pixar dot com
@ 2006-01-21 22:33 ` jbuck at welsh-buck dot org
  1 sibling, 0 replies; 14+ messages in thread
From: jbuck at welsh-buck dot org @ 2006-01-21 22:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from jbuck at welsh-buck dot org  2006-01-21 22:33 -------
Subject: Re:  gcov misreports coverage of return statement
        [NVR]

On Thu, 2005-10-27 at 01:41 +0000, reddy at pixar dot com wrote:
> 
> ------- Comment #12 from reddy at pixar dot com  2005-10-27 01:41 -------
> Having code coverage emit a "-" instead of "#####" in this case sounds
> appropriate and would certainly solve the problem for me.
> 
> Is there a way to workaround this issue by reorganizing code, or something
> else, so that I can fool the NVR smarts into not getting invoked in this
> particular case?

The -fno-elide-constructors flag helps; it forces explicit copy constructor
calls, and that seems to get rid of most of the bogons -- but apparently
not all of them -- I'll look further, but I think sometimes the
initializer for a base class gets optimized in a way that results in a
false ###### flagging.  Still, if you're having this trouble, start with
that flag.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/12076] gcov misreports coverage of return statement [NVR]
       [not found] <bug-12076-6823@http.gcc.gnu.org/bugzilla/>
@ 2005-10-27  1:41 ` reddy at pixar dot com
  2006-01-21 22:33 ` jbuck at welsh-buck dot org
  1 sibling, 0 replies; 14+ messages in thread
From: reddy at pixar dot com @ 2005-10-27  1:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from reddy at pixar dot com  2005-10-27 01:41 -------
Having code coverage emit a "-" instead of "#####" in this case sounds
appropriate and would certainly solve the problem for me.

Is there a way to workaround this issue by reorganizing code, or something
else, so that I can fool the NVR smarts into not getting invoked in this
particular case?


-- 

reddy at pixar dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reddy at pixar dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12076


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2006-01-21 22:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-27  9:34 [Bug c++/12076] New: gcov misreports coverage of return statement r dot lichtenberger at icoserve dot com
2003-08-27 14:05 ` [Bug c++/12076] " bangerth at dealii dot org
2003-11-28  8:02 ` [Bug other/12076] gcov misreports coverage of return statement (for inline functions) pinskia at gcc dot gnu dot org
2003-11-28  9:11 ` r dot lichtenberger at icoserve dot com
2003-11-28 17:47 ` pinskia at gcc dot gnu dot org
2003-12-01  6:27 ` r dot lichtenberger at icoserve dot com
2003-12-01  6:33 ` pinskia at gcc dot gnu dot org
2003-12-26 23:11 ` pinskia at gcc dot gnu dot org
2004-05-21 21:52 ` pinskia at gcc dot gnu dot org
2004-08-13  0:04 ` pinskia at gcc dot gnu dot org
2005-07-25  1:52 ` [Bug c++/12076] gcov misreports coverage of return statement [NVR] pinskia at gcc dot gnu dot org
2005-07-25 21:04 ` jbuck at gcc dot gnu dot org
     [not found] <bug-12076-6823@http.gcc.gnu.org/bugzilla/>
2005-10-27  1:41 ` reddy at pixar dot com
2006-01-21 22:33 ` jbuck at welsh-buck dot org

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).