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: unassignedclangb...@nondot.org
          Reporter: haoxi...@gmail.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to