[LLVMbugs] [Bug 677] NEW: Pure virtual class function results in invalid emitted C code

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Dec 15 05:04:17 PST 2005


           Summary: Pure virtual class function results in invalid emitted C
           Product: tools
           Version: 1.6
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: llc
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: satayguy_junk at yahoo.com.sg

Defining a pure virtual class function in a C++ class results in code that can
compiled and interpreted lli. However, compiling the emitted C code results in a
linking error.

Reproduction Steps
1. The following files were created. (See below for source codes)
   i) main.cpp
   ii) module.h
   iii) module.cpp

2. They were then compiled using the following commands.
   # llvm-g++ -o main main.cpp
   # llvm-g++ -c -o module.bc module.cpp
   # llvm-link -f -o=generated.bc main.bc module.bc
   # llc -f -march=c -o=generated.c generated.bc

3. Running generated.bc has no problems.
   # lli generated.bc
   Class 1::TestAbstract called

4. However, compiling the generated.c source file results in a linker error.
   # gcc generated.c
   generated.c:159: warning: conflicting types for built-in function 'malloc'
   /tmp/ccKoyQ2T.o(.data+0x68): undefined reference to `__cxa_pure_virtual'
   /tmp/ccKoyQ2T.o(.data+0x8c): undefined reference to `vtable for
   /tmp/ccKoyQ2T.o(.data+0x98): undefined reference to `vtable for

PC System
Distro: Fedora Core 3
Arch: x86
Kernel version: Linux 2.6.9-1.667
GCC version: gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
LLVM version: 1.6
LLVM GCC Frontend version: 1.6 GCC Front End Binaries for Linux/x86

Source Codes
i. main.cpp
#include <stdio.h>
#include <string.h>
#include "module.h"

int main(void)
	CClass1 class1;


ii. module.h
class CAbstract
	virtual void TestAbstract() = 0;

class CClass1 : public CAbstract
	void TestAbstract();

iii. module.cpp
#include <string.h>
#include <stdio.h>
#include "module.h"

void CClass1::TestAbstract()
	printf("Class 1::TestAbstract called\n");

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the llvm-bugs mailing list