You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When compiling the following example with clang -O3 opt level, the program does not print the expected output and the returned status is 48.
Steps to reproduce:
1. cat bug.cpp
#include <stdio.h>
#include <stdlib.h>
struct C {
int i[100000000];
};
int main()
{
// Eat all available chunks of memory that are big enough for
// struct C so that the next allocation request will fail.
while (malloc(sizeof(struct C)));
printf("End\n");
return 0;
}
2. clang++ bug.cpp -O3
3. ./a.out
4. echo $?
48
This is the generated LLVM IR after the optimizations. The loop is optimized away and so is 'printf':
When compiling the following example with clang -O3 opt level, the program does not print the expected output and the returned status is 48.
Steps to reproduce:
This is the generated LLVM IR after the optimizations. The loop is optimized away and so is 'printf':
Compiling the same example with GCC, the program produces the expected output:
The text was updated successfully, but these errors were encountered: