This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/21964] New: broken tail call at -O2 or more


Optimisations seem to cause the post increment in the recursive function call to
foo() to pass the increased value to the function.

Expected output, and output when compiled without -O2:
0
0
0
0
...

Actual output with -O2 or -O3 or...:
0
1
2
3
...

#include <stdio.h>
 
void foo(int n);
 
int main(void) {
    foo(0);
 
    return 0;
}
 
void foo(int n) {
    printf("%d\n", n);
    foo(n++);
}

-- 
           Summary: broken tail call at -O2 or more
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ben at 0x539 dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21964


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]