This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11767] New: different code behaviour with -fprofile-arcs -ftest-coverage


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

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

           Summary: different code behaviour with -fprofile-arcs -ftest-
                    coverage
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lothar at xcerla dot com
                CC: gcc-bugs at gcc dot gnu dot org

lothar@janus$ gcc --version
gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

The code behaviour is different if I compile with -fprofile-arcs
-ftest-coverage or not. In both cases I compiled with -O0 (no
optimizations). I noticed it, as some of my cppunit tests failed. Here
is one of the tests: It basically only stores a value in a class which
acts as a wrapper to the GNU MP library and get's the same value back.
To my surprise the value I get back is both, the same and not the same
as I put in (at least according to the C++ comparison operators
available).

  void gccbug ( void )
  {
    {
      signed long const c_v(5);
      RawInteger i(c_v);
      signed long const c_v2(i.valueSignedLong());
      
      std::cout << "long " << std::endl
                << c_v2 << " "
                << c_v  << " "
                << (c_v2 > c_v)  << " "
                << (c_v2 >= c_v) << " "
                << (c_v2 < c_v)  << " "
                << (c_v2 <= c_v) << " "
                << (c_v2 == c_v) << " "
                << (c_v2 != c_v) << " "
                << std::endl;
    }
    {
      double const c_v(5.0);
      RawInteger i(c_v);
      double const c_v2(i.valueDouble());
      
      std::cout << "double " << std::endl
                << c_v2 << " "
                << c_v  << " "
                << (c_v2 > c_v)  << " "
                << (c_v2 >= c_v) << " "
                << (c_v2 < c_v)  << " "
                << (c_v2 <= c_v) << " "
                << (c_v2 == c_v) << " "
                << (c_v2 != c_v) << " "
                << std::endl;
    }
  }


Here's the output of this code fragment:
  without code coverage:
long
5 5 0 1 0 1 1 0
double
5 5 0 1 0 1 1 0

  with code coverage:
long
5 5 0 1 0 1 1 0
double
5 5 0 1 0 1 0 1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]