Issue |
83728
|
Summary |
Clang doesn't warn about reading beyond the end of a source sequence.
|
Labels |
clang
|
Assignees |
|
Reporter |
mushenoy
|
GCC reports warning for calls to string manipulation functions such as memchr, or strcpy that are determined to read past the end of the source sequence ([-Wstringop-overread])
Similar warnings are not reported in Clang.
Sample Program:
```
#include <string.h>
int main () {
int dest[10];
int src[5] = {1,2,3,4,5};
memcpy (dest, src, 10*sizeof (int));
return 0;
}
```
Compilation with Clang:
No warnings reported
```
# clang -c -Wall stringop_overread.c
#
```
Compilation with GCC:
```
# gcc -c -Wall stringop_overread.c
stringop_overread.c: In function _main_:
stringop_overread.c:6:9: warning: memcpy reading 40 bytes from a region of size 20 [-Wstringop-overread]
6 | memcpy (dest, src, 10*sizeof (int));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stringop_overread.c:5:13: note: source object src of size 20
5 | int src[5] = {1,2,3,4,5};
| ^~~
```
Compiler Versions:
```
clang version 16.0.6
gcc (GCC) 13.2.1
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs