https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67979

            Bug ID: 67979
           Summary: dead code elimination deleted the predicated branch
                    within the function block.
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: feqin1023 at gmail dot com
  Target Milestone: ---

Created attachment 36518
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36518&action=edit
the source test dead code elimination.

if i have this input:

/*--------------------test.c----------------------------*/
void bar_i(int);
void foo(int *x) {
  int y = *x; // dead code can be clean
  if (!x)
    return;   // this branch ALSO will be clean 
  bar_i(y);
}
/*------------------------------------------------------*/

we call gcc like this:

  gcc -O2 -S test.c

the the whole branch in function foo(int *) will be clean.
BUT, if foo(int *) is called like this:

  foo(NULL);

gcc has CHANGED the original semantic even sometimes which
 is error. but compiler can do this?

I also test Clang, Clang ALWAYS keep the branch in foo(int *).

Reply via email to