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]

C++ code generation problem with -fprofile-arcs -ftest-coverage


Hi there,

I have already reported (on 10 Apr 1998) that coverage testing
stopped working in the transition from egcs-1.02 to egcs-1.03.
Since I need this feature, I am tracking the snapshots to
see if things improve. Doing that I discovered another problem:
with the latest snapshot (egcs-19980803) compiling with
-fprofile-arcs -ftest-coverage gives rise to a linking-time
error concerning a symbol that has multiple definitions.
I believe that the actual problem can be reproduced
by a one-line program given below.

My machine is

$ uname -a
Linux rugby 2.0.32 #6 Sun Mar 22 22:05:21 CET 1998 i586 unknown

My egcs is

$ /u/local/bin/g++ -v
Reading specs from /u/local/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.53/specs
gcc version egcs-2.91.53 19980803 (gcc2 ss-980609 experimental)

The error I get linking my application is

Prolog2C_CNet.o: In function `global constructors keyed to int
lexicographical_compare_3way<signed char const *, signed char const *>(signed
char const *, signed char const *, signed char const *, signed char const
*)(volatile const)':
/u/local/include/g++/stl_algobase.h:427: multiple definition of `global
constructors keyed to int lexicographical_compare_3way<signed char const *,
signed char const *>(signed char const *, signed char const *, signed char const
*, signed char const *)(volatile const)'
Defness/New-Defness.o:/u/local/include/g++/stl_algobase.h:427: first defined
here
collect2: ld returned 1 exit status

To reproduce what I believe is the actual problem,
I do this:

$ cat bug.cc
#include <vector>
$ /u/local/bin/g++ -Wall -W -g -fprofile-arcs -ftest-coverage -fno-exceptions -c
bug.cc -o bug.o
$ nm --demangle bug.o
000000aa ? .LBE2
000000b8 ? .LBE3
00000000 ? .LM1
00000000 ? .LM10
0000000d ? .LM11
0000000e ? .LM12
00000032 ? .LM13
00000050 ? .LM14
00000070 ? .LM15
00000082 ? .LM16
0000008a ? .LM17
000000a7 ? .LM18
000000b8 ? .LM19
0000000d ? .LM2
0000000d ? .LM3
00000032 ? .LM4
0000003e ? .LM5
00000042 ? .LM6
0000004e ? .LM7
00000072 ? .LM8
000000aa ? .LM9
000000b4 ? .Lscope0
000000bc ? .Lscope1
00000000 ? .Ltext1
00000000 T global constructors keyed to int lexicographical_compare_3way<signed
char const *, signed char const *>(signed char const *, signed char const *,
signed char const *, signed char const *)(volatile const)
0000000c r __WORD_BIT
         U __bb_init_func
00000000 W int lexicographical_compare_3way<signed char const *, signed char
const *>(signed char const *, signed char const *, signed char const *, signed
char const *)
00000000 W bool lexicographical_compare<signed char const *, signed char const
*>(signed char const *, signed char const *, signed char const *, signed char
const *)
$ /u/local/bin/g++ -Wall -W -g -fno-exceptions -c bug.cc -o bug.o
$ nm --demangle bug.o
00000058 ? .LBE2
00000077 ? .LBE3
00000000 ? .LM1
00000000 ? .LM10
00000003 ? .LM11
00000004 ? .LM12
00000018 ? .LM13
00000030 ? .LM14
00000043 ? .LM15
00000050 ? .LM16
00000058 ? .LM17
00000070 ? .LM18
00000077 ? .LM19
00000003 ? .LM2
00000003 ? .LM3
00000018 ? .LM4
00000024 ? .LM5
00000028 ? .LM6
00000034 ? .LM7
00000040 ? .LM8
00000058 ? .LM9
0000005c ? .Lscope0
0000007b ? .Lscope1
00000000 ? .Ltext1
0000000c r __WORD_BIT
00000000 W int lexicographical_compare_3way<signed char const *, signed char
const *>(signed char const *, signed char const *, signed char const *, signed
char const *)
00000000 W bool lexicographical_compare<signed char const *, signed char const
*>(signed char const *, signed char const *, signed char const *, signed char
const *)
$

As you can see, when using -fprofile-arcs -ftest-coverage
a (non-weak) symbol

    global constructors keyed to
    int lexicographical_compare_3way<signed char const *,
                                     signed char const *>(signed char const *,
                                                          signed char const *,
                                                          signed char const *,
                                                          signed char const *)
         (volatile const)

is put into the text section. And, as far as I can see, this happens for
any file that includes <vector>. Trying to link together more than one
object whose source includes <vector> gives rise to the multiply defined
symbol.

Let me conclude with a question: is test coverage something you
want operational for egcs-1.1? If so, I will try to provide good
reports for the other things that prevent it from working (in other
words, I can get around the bug I am reporting now, but
-fprofile-arcs -ftest-coverage still doesn't work).

Thanks a lot for all your efforts,

        Roberto

-- 
Roberto Bagnara
Department of Mathematics, University of Parma, Italy
http://www.di.unipi.it/~bagnara/bagnara.html
mailto:bagnara@di.unipi.it


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