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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to