Issue 64684
Summary Undefined behavior sanitizer missed case with uninitialized arrays
Labels enhancement, compiler-rt:ubsan
Assignees
Reporter wheatman
    I found this based on reading https://discourse.llvm.org/t/clang-assigning-an-uninitialized-array-to-another-array-produces-undefined-behavior-with-optimization-o1/72763 

the following code which I believe is undefined behavior based on 
`the value of an object with automatic storage duration is used while it is indeterminateā€ (C99 draft).`

is not detected by `-fsanitize=undefined,address`

```
#include <stdio.h>

#define N 4
int ia[N];
int main (void) { 
    int i, ib[N];
  
    for (i = 0; i < N; i++)
        ia[i] = ib[i];

    /* check results: */  
    for (i = 0; i < N; i++)
       printf("%d : %d\n",ia[i], ib[i]);

    return 0;
}

```
The output does change based on optimization levels which indicates to me that this is undefined behavior 

https://godbolt.org/z/s9T6TdEbd
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to