Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] wrong code at -O0 #98007

Closed
bi6c opened this issue Jul 8, 2024 · 1 comment
Closed

[clang] wrong code at -O0 #98007

bi6c opened this issue Jul 8, 2024 · 1 comment
Labels
obsolete Issues with old (unsupported) versions of LLVM

Comments

@bi6c
Copy link

bi6c commented Jul 8, 2024

#include<stdint.h>
#include<stdio.h>

static long __undefined;

static int8_t g_3[1] = {0x03L};
static int32_t g_5 = 0x4B283066L;

int main (int argc, char* argv[])
{
    int8_t * const l_2 = &g_3[0];
    g_5 |= (l_2 != &g_3[0]);
    printf("%d", g_5);
    return 0;
}

Hello, we are using clang to compile the above code in Ubuntu 22.04.3 LTS.
We found a case that there are discrepancies when compiling with llvmorg-14.0.6 at optimization levels -O0.

$ ../compiler-builds/llvmorg-14.0.6_build/bin/clang -fsanitize=undefined -fsanitize=address --rtlib=compiler-rt -g -lgcc_s -I/home/csmith/include/csmith-2.3.0 -O0 testcase.c -o exec

$ timeout 1s ./exec 2>exec.err
1260925031

$ ../compiler-builds/llvmorg-13.0.1_build/bin/clang -fsanitize=undefined -fsanitize=address --rtlib=compiler-rt -g -lgcc_s -I/home/csmith/include/csmith-2.3.0 -O0 testcase.c -o exec

$ timeout 1s ./exec 2>exec.err
1260925030
@github-actions github-actions bot added the clang Clang issues not falling into any other category label Jul 8, 2024
@nikic
Copy link
Contributor

nikic commented Jul 8, 2024

Does not reproduce in clang 15 or above: https://c.godbolt.org/z/PqM5PfE7E

@nikic nikic closed this as not planned Won't fix, can't repro, duplicate, stale Jul 8, 2024
@nikic nikic added the invalid Resolved as invalid, i.e. not a bug label Jul 8, 2024
@EugeneZelenko EugeneZelenko added obsolete Issues with old (unsupported) versions of LLVM and removed clang Clang issues not falling into any other category invalid Resolved as invalid, i.e. not a bug labels Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
obsolete Issues with old (unsupported) versions of LLVM
Projects
None yet
Development

No branches or pull requests

3 participants