[LLVMbugs] [Bug 17739] New: Omitting return statement in non-void function causes return instruction to be omitted

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 30 10:25:26 PDT 2013


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

            Bug ID: 17739
           Summary: Omitting return statement in non-void function causes
                    return instruction to be omitted
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tobias.haegermarck at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code (must be compiled with clang++ -O1 to trigger)

#include <stdio.h>
int foo() { printf("bar"); }
int main() {
        foo();
        return 0;
}

Causes the terminal to spam with "bar" until the stack fills up and the program
segfaults, due to that no ret instruction after the call to printf is generated

This does generate a warning
Yes, this is sort of a duplicate of http://llvm.org/bugs/show_bug.cgi?id=16071
, but wontfix, really? At least upgrade the warning to an error if its gonna
crash everything in completely nonsensical ways

Also very much worthy of noting that from what I can see on the llvm-dis
output, printf is meant to be tail called (e.g jmp), which doesnt seem to
happen, but I'm not terribly experienced with that

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131030/41ef8d6a/attachment.html>


More information about the llvm-bugs mailing list