[llvm-bugs] [Bug 33299] New: functions with empty body are wrongly optimized

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 4 05:51:43 PDT 2017


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

            Bug ID: 33299
           Summary: functions with empty body are wrongly optimized
           Product: clang
           Version: 4.0
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yangyibiao at nju.edu.cn
                CC: llvm-bugs at lists.llvm.org

Created attachment 18571
  --> https://bugs.llvm.org/attachment.cgi?id=18571&action=edit
the test file for reproduce this bug

/* test.c */
#include "stdio.h"

static int g;
static int arr[2] = {0, 1};

static int f1() 
{
    // function with empty body
}

static void f()
{
    g = f1();
}

void main(int argc, char **argv)
{
    f();
    printf("%d\n", arr[g]);
}
/* end of test.c */


With/without optimization when compiling the attached file "test.c", the
outputs are different.

the command for compile the attached file is as follows:

$ clang -O0 test.c -o test0
$ clang -O1 test.c -o test1
$ clang -O2 test.c -o test2
$ clang -O3 test.c -o test3
$ clang -Ofast test.c -o test4

-- 
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/20170604/fa3798ef/attachment-0001.html>


More information about the llvm-bugs mailing list