[LLVMbugs] [Bug 18541] New: Using the main function in a program is allowed

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jan 19 00:56:01 PST 2014


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

            Bug ID: 18541
           Summary: Using the main function in a program is allowed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ville.voutilainen at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This causes an infinite loop:

int main() {auto* x = &main; x();}

[basic.start.main]/3 states:

"The function main shall not be used within a program."

I can even do things like

int x = 0; int main() {auto* f = &main; if (++x == 0) f();}

which run correctly.

gcc rejects taking the address of main.

-- 
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/20140119/234a9a56/attachment.html>


More information about the llvm-bugs mailing list