[llvm-bugs] [Bug 45121] New: Segmentation fault in simple function call using O1 ~ Os

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 5 07:48:45 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=45121

            Bug ID: 45121
           Summary: Segmentation fault in simple function call using O1 ~
                    Os
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Hi, the test.c

#include <stdio.h>

void foo( ) {
while(1){} 
//do {}while(1); //crash
//for(;;); //crash
while(-1){}  // non-executed loop, but still crash
}
int main () {
    int size = 100;
    printf("size = %d\n", size);
    foo();
    return 0;
}

is a simple function call code. When I compiler is using `clang-6.0 -O1 test.c`
(or O2, O3, and Os) and then `./a.out`, the output is 

size=100
size=100
Segmentation fault(code dumped).

The strange thing is that `printf` function executed twice and whatever loop I
use in the function foo(), even a non-executed loop, it gets faults.

-- 
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/20200305/2b7f93bf/attachment.html>


More information about the llvm-bugs mailing list