[LLVMbugs] [Bug 3612] New: printf(printf); leads to invalid codegen and no diagnosis

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Feb 18 10:43:03 PST 2009


http://llvm.org/bugs/show_bug.cgi?id=3612

           Summary: printf(printf); leads to invalid codegen and no
                    diagnosis
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: alexei.svitkine at gmail.com
                CC: llvmbugs at cs.uiuc.edu


This is a new bug. It used to generated expected results a week ago
(diagnostics and expected code gen).

Compiling the following code:

#include <stdio.h>

int foo(void) {
  return printf(printf);
}

Results in the following codegen'd function (and no diagnostics from clang!):

define i32 @__ccons_anon1() nounwind {
entry:
        %retval = alloca i32            ; <i32*> [#uses=2]
        %call = call i32 (i8*, ...)* @printf(i8* bitcast (i32 (i8*, ...)*
@printf1 to i8*))             ; <i32> [#uses=1]
        store i32 %call, i32* %retval
        %0 = load i32* %retval          ; <i32> [#uses=1]
        ret i32 %0
}

When this function is then attempted to be executed with llvm, it results in
the following assert:

ERROR: Program used external function 'printf1' which could not be resolved!

The expected behaviour (which used to be the case 1 week ago or so) is:

First of all, diagnostics produced due to incorrect pointer type being passed.
Second of all, the calling of foo() succeeding and printf treating a pointer to
itself as a string and printing some garbage (until it encounters a zero).


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list