public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12326] New: Thunk not generated for virtual func
@ 2003-09-18 11:49 thomas at koeller dot dyndns dot org
  2003-09-18 15:41 ` [Bug c++/12326] " thomas at koeller dot dyndns dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: thomas at koeller dot dyndns dot org @ 2003-09-18 11:49 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=12326

           Summary: Thunk not generated for virtual func
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thomas at koeller dot dyndns dot org
                CC: gcc-bugs at gcc dot gnu dot org,thomas dot koeller at
                    baslerweb dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

If both -fvtable-gc and -ffunction-sections are given to the compiler and the linker (GNU ld)  
is invoked with --gc-sections, then virtual functions are eliminated in spite of being called,  
and no thunks are generated for these functions either. A set of files to reproduce the  
problem is included at the end of this PR.  
  
When the program is built with the Makefile included, the output from nm shows that  
neither the function Drvd::func2() nor a thunk for it is present in the executable. Its vtable  
slot is zeroed and the program segfaults.  
  
bash-2.05b$ nm -C testprog | grep '.*::func'  
08048298 T Drvd::func1()  
bash-2.05b$ testprog  
Segmentation fault  
bash-2.05b$  
  
If I leave out -fvtable-gc, then the output from nm looks ok and the program runs fine.  
  
bash-2.05b$ nm -C testprog | grep '.*::func'  
08048298 T Drvd::func1()  
0804829e T Drvd::func2()  
080482a4 W non-virtual thunk to Drvd::func2()  
bash-2.05b$ testprog  
bash-2.05b$  
  
These are the files to reproduce the bug (why can't I just attach a tar.bz2 archive?):  
  
Makefile:  
-----------------------------------------------------------------------------------------------------------------------------  
APPNAME		:= testprog  
CXX		:= /opt/gcc/bin/g++  
CXXFLAGS	:= -O0 -ggdb2  -fno-rtti -ffunction-sections -fdata-sections \  
		   -fvtable-gc  
LD		:= $(CXX)  
LDFLAGS		:= -static -O0 -Wl,-Map -Wl,$(APPNAME).map -Wl,--gc-sections  
RM		:= rm  
RMFLAGS		:= -f  
  
.PHONY		: all clean  
  
all		: $(APPNAME)  
  
$(APPNAME)	: testprog.o drvd.o  
	$(LD) $(LDFLAGS) -o $@ $^  
  
testprog.o	: testprog.cxx testprog.hxx  
	$(CXX) $(CXXFLAGS) -c -o $@ $<  
  
drvd.o		: drvd.cxx testprog.hxx  
	$(CXX) $(CXXFLAGS) -c -o $@ $<  
  
clean		:  
	$(RM) $(RMFLAGS) testprog.o drvd.o $(APPNAME) $(APPNAME).map  
-----------------------------------------------------------------------------------------------------------------------------  
  
testprog.hxx:  
-----------------------------------------------------------------------------------------------------------------------------  
#if !defined (TESTPROG_HXX)  
#define TESTPROG_HXX  
  
class Base1  
{  
  public:  
    virtual void func1(void) = 0;  
};  
  
class Base2  
{  
  public:  
    virtual void func2(void) = 0;  
};  
  
class Drvd : public Base1, public Base2  
{  
  public:  
    virtual void func1(void);  
    virtual void func2(void);  
};  
  
#endif // !defined (TESTPROG_HXX)  
-----------------------------------------------------------------------------------------------------------------------------  
  
testprog.cxx:  
-----------------------------------------------------------------------------------------------------------------------------  
#include "testprog.hxx"  
  
Drvd drvd;  
  
int  
main(void)  
{  
  Base1 &base1(drvd);  
  Base2 &base2(drvd);  
  
  base1.func1();  
  base2.func2();  
  return 0;  
};  
-----------------------------------------------------------------------------------------------------------------------------  
  
drvd.cxx:  
-----------------------------------------------------------------------------------------------------------------------------  
#include "testprog.hxx"  
  
void  
Drvd::func1(void)  
{  
}  
  
void  
Drvd::func2(void)  
{  
}  
-----------------------------------------------------------------------------------------------------------------------------


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

* [Bug c++/12326] Thunk not generated for virtual func
  2003-09-18 11:49 [Bug c++/12326] New: Thunk not generated for virtual func thomas at koeller dot dyndns dot org
@ 2003-09-18 15:41 ` thomas at koeller dot dyndns dot org
  2003-09-18 15:49 ` thomas at koeller dot dyndns dot org
  2003-09-18 15:55 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: thomas at koeller dot dyndns dot org @ 2003-09-18 15:41 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=12326



------- Additional Comments From thomas at koeller dot dyndns dot org  2003-09-18 14:59 -------
I just found out that my PR is a duplicate of #1622, which is marked as FIXED. However, 
the problem still exists in 3.3.


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

* [Bug c++/12326] Thunk not generated for virtual func
  2003-09-18 11:49 [Bug c++/12326] New: Thunk not generated for virtual func thomas at koeller dot dyndns dot org
  2003-09-18 15:41 ` [Bug c++/12326] " thomas at koeller dot dyndns dot org
@ 2003-09-18 15:49 ` thomas at koeller dot dyndns dot org
  2003-09-18 15:55 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: thomas at koeller dot dyndns dot org @ 2003-09-18 15:49 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=12326



------- Additional Comments From thomas at koeller dot dyndns dot org  2003-09-18 15:34 -------
I just found out that my PR is a duplicate of #1622, which is marked as FIXED. However,  
the problem still exists in 3.3.


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

* [Bug c++/12326] Thunk not generated for virtual func
  2003-09-18 11:49 [Bug c++/12326] New: Thunk not generated for virtual func thomas at koeller dot dyndns dot org
  2003-09-18 15:41 ` [Bug c++/12326] " thomas at koeller dot dyndns dot org
  2003-09-18 15:49 ` thomas at koeller dot dyndns dot org
@ 2003-09-18 15:55 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-09-18 15:55 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=12326


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WONTFIX


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-09-18 15:47 -------
-fvtable-gc is gone in the mainline so closing as will not fix, sorry.


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

end of thread, other threads:[~2003-09-18 15:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-18 11:49 [Bug c++/12326] New: Thunk not generated for virtual func thomas at koeller dot dyndns dot org
2003-09-18 15:41 ` [Bug c++/12326] " thomas at koeller dot dyndns dot org
2003-09-18 15:49 ` thomas at koeller dot dyndns dot org
2003-09-18 15:55 ` pinskia at gcc dot gnu 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).