[LLVMbugs] [Bug 355] NEW: [llvmg++] Miscompiling a simple C++ program!

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Jun 2 23:43:21 PDT 2004


http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=355

           Summary: [llvmg++] Miscompiling a simple C++ program!
           Product: tools
           Version: 1.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: llvm-g++
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sabre at nondot.org


This testcase (distilled from a gigantic STL .ii file):

----
struct normal_iterator {};

typedef normal_iterator<int*> iterator;

void foo(iterator);
void bar() {
  foo(iterator());
}
----

Is currently being miscompiled to this horrible code:

----
        "struct.normal_iterator<int*>" = type { ubyte }

declare void %_Z3foo15normal_iteratorIPiE("struct.normal_iterator<int*>")

void %_Z3barv() {
entry:
        call void cast (void ("struct.normal_iterator<int*>")*
%_Z3foo15normal_iteratorIPiE to void (ubyte)*)( ubyte 0 )
        ret void
}
----

Note that the "foo" function is taking the structure *by value* which is very
illegal in LLVM.  We never noticed this before because the verifier was not
checking this particular case, and it appears that it only happens to external
functions.  This is probably why we get occasional spurious linker warnings when
compiling C++ programs.

I fixed the verifier to check for this case:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040531/014971.html

... but the C++ front-end still must be fixed.

-Chris



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