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

            Bug ID: 92930
           Summary: GCC incorrectly optimizes away __builtin_apply() calls
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: green at redhat dot com
  Target Milestone: ---

Compile the following with -O2 and it optimizes away the call to bar()/foo(). 
This is incorrect, as foo() may have side-effects.


void foo(int a, int b, int c, int d, int e, int f, int g);

static void bar(int a, ...)
{
  __builtin_apply(foo, __builtin_apply_args(), 20);
}

int main(void)
{
  bar(1024, 1025, 1026, 1027, 1028, 1029, 1030);

  return 0;
}

Reply via email to